Skip to content

Commit

Permalink
Nav, Docking: fix dimming crash with accessing zero-cmd ImDrawList (a…
Browse files Browse the repository at this point in the history
…mend 1dc3af3, 23ef6c1)

# Conflicts:
#	imgui.cpp
  • Loading branch information
ocornut committed Dec 6, 2021
1 parent 20e040c commit bdf6cf3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ bool ImGuiListClipper::Step()
IM_ASSERT(table->RowPosY1 == StartPosY && table->RowPosY2 == window->DC.CursorPos.y);

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

Expand Down Expand Up @@ -4456,7 +4456,6 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
// Draw behind window by moving the draw command at the FRONT of the draw list
{
ImDrawList* draw_list = window->RootWindow->DrawList;
draw_list->AddDrawCmd();
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // Ensure ImDrawCmd are not merged
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
ImDrawCmd cmd = draw_list->CmdBuffer.back();
Expand Down Expand Up @@ -4608,6 +4607,10 @@ void ImGui::Render()
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
}

// Draw modal/window whitening backgrounds
if (first_render_of_frame)
RenderDimmedBackgrounds();

// Add ImDrawList to render
ImGuiWindow* windows_to_render_top_most[2];
windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
Expand All @@ -4623,10 +4626,6 @@ void ImGui::Render()
if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window
AddRootWindowToDrawData(windows_to_render_top_most[n]);

// Draw modal/window whitening backgrounds
if (first_render_of_frame)
RenderDimmedBackgrounds();

// Setup ImDrawData structures for end-user
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
for (int n = 0; n < g.Viewports.Size; n++)
Expand Down

0 comments on commit bdf6cf3

Please sign in to comment.