Skip to content

Commit

Permalink
ImDrawData: call _PopUnusedDrawCmd() later. as RenderDimmedBackground…
Browse files Browse the repository at this point in the history
…s() rely on a valid command being there (especially in docking branch). (#6406, #4879, #1878)

Amend/fix dbeeeae for docking.
+ Build fix when using IMGUI_DISABLE_DEBUG_TOOLS
  • Loading branch information
ocornut committed Jul 12, 2023
1 parent 0110f4c commit 023e59a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5356,8 +5356,12 @@ void ImGui::Render()
if (viewport->DrawLists[1] != NULL)
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));

// We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
ImDrawData* draw_data = &viewport->DrawDataP;
IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
for (int draw_list_n = 0; draw_list_n < draw_data->CmdLists.Size; draw_list_n++)
draw_data->CmdLists[draw_list_n]->_PopUnusedDrawCmd();

g.IO.MetricsRenderVertices += draw_data->TotalVtxCount;
g.IO.MetricsRenderIndices += draw_data->TotalIdxCount;
}
Expand Down
2 changes: 1 addition & 1 deletion imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,6 @@ void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>

// Add to output list + records state in ImDrawData
out_list->push_back(draw_list);
draw_list->_PopUnusedDrawCmd();
draw_data->CmdListsCount++;
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
Expand All @@ -1868,6 +1867,7 @@ void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>
void ImDrawData::AddDrawList(ImDrawList* draw_list)
{
IM_ASSERT(CmdLists.Size == CmdListsCount);
draw_list->_PopUnusedDrawCmd();
ImGui::AddDrawListToDrawDataEx(this, &CmdLists, draw_list);
}

Expand Down

0 comments on commit 023e59a

Please sign in to comment.