Skip to content

Commit a4ebe3d

Browse files
committed
Viewports: Fixed assertion when multi-viewports disabled and no monitor submitted. Reworked 95c4111. (ocornut#8401, ocornut#8393, ocornut#8385)
1 parent 95c4111 commit a4ebe3d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

imgui.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -16117,6 +16117,8 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const
1611716117
// This is so we can select an appropriate font size on the first frame of our window lifetime
1611816118
if (viewport->PlatformMonitor != -1)
1611916119
viewport->DpiScale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
16120+
else
16121+
viewport->DpiScale = 1.0f;
1612016122
}
1612116123

1612216124
viewport->Window = window;
@@ -16536,9 +16538,8 @@ static int ImGui::FindPlatformMonitorForRect(const ImRect& rect)
1653616538
ImGuiContext& g = *GImGui;
1653716539

1653816540
const int monitor_count = g.PlatformIO.Monitors.Size;
16539-
IM_ASSERT(monitor_count > 0);
1654016541
if (monitor_count <= 1)
16541-
return 0;
16542+
return monitor_count - 1;
1654216543

1654316544
// Use a minimum threshold of 1.0f so a zero-sized rect won't false positive, and will still find the correct monitor given its position.
1654416545
// This is necessary for tooltips which always resize down to zero at first.

0 commit comments

Comments
 (0)