Skip to content

Commit 657073a

Browse files
committed
Nav, Docking: fix dimming crash with accessing zero-cmd ImDrawList (amend 1dc3af3, 23ef6c1)
# Conflicts: # imgui.cpp
1 parent 20e040c commit 657073a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

imgui.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ bool ImGuiListClipper::Step()
24762476
IM_ASSERT(table->RowPosY1 == StartPosY && table->RowPosY2 == window->DC.CursorPos.y);
24772477

24782478
ItemsHeight = (window->DC.CursorPos.y - StartPosY) / (float)(DisplayEnd - DisplayStart);
2479-
float affected_by_floating_point_precision = ImIsFloatAboveGuaranteedIntegerPrecision(StartPosY) || ImIsFloatAboveGuaranteedIntegerPrecision(window->DC.CursorPos.y);
2479+
bool affected_by_floating_point_precision = ImIsFloatAboveGuaranteedIntegerPrecision(StartPosY) || ImIsFloatAboveGuaranteedIntegerPrecision(window->DC.CursorPos.y);
24802480
if (affected_by_floating_point_precision)
24812481
ItemsHeight = window->DC.PrevLineSize.y + g.Style.ItemSpacing.y; // FIXME: Technically wouldn't allow multi-line entries.
24822482

@@ -4456,13 +4456,13 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
44564456
// Draw behind window by moving the draw command at the FRONT of the draw list
44574457
{
44584458
ImDrawList* draw_list = window->RootWindow->DrawList;
4459-
draw_list->AddDrawCmd();
44604459
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // Ensure ImDrawCmd are not merged
44614460
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
44624461
ImDrawCmd cmd = draw_list->CmdBuffer.back();
44634462
IM_ASSERT(cmd.ElemCount == 6);
44644463
draw_list->CmdBuffer.pop_back();
44654464
draw_list->CmdBuffer.push_front(cmd);
4465+
draw_list->PopClipRect();
44664466
}
44674467
}
44684468

@@ -4608,6 +4608,10 @@ void ImGui::Render()
46084608
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
46094609
}
46104610

4611+
// Draw modal/window whitening backgrounds
4612+
if (first_render_of_frame)
4613+
RenderDimmedBackgrounds();
4614+
46114615
// Add ImDrawList to render
46124616
ImGuiWindow* windows_to_render_top_most[2];
46134617
windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
@@ -4623,10 +4627,6 @@ void ImGui::Render()
46234627
if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window
46244628
AddRootWindowToDrawData(windows_to_render_top_most[n]);
46254629

4626-
// Draw modal/window whitening backgrounds
4627-
if (first_render_of_frame)
4628-
RenderDimmedBackgrounds();
4629-
46304630
// Setup ImDrawData structures for end-user
46314631
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
46324632
for (int n = 0; n < g.Viewports.Size; n++)

0 commit comments

Comments
 (0)