Skip to content

Commit d66f4e5

Browse files
committed
Asserting for invalid DpIScale values. (ocornut#8156)
1 parent 8082a84 commit d66f4e5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

imgui.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -11050,7 +11050,7 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
1105011050
IM_UNUSED(mon);
1105111051
IM_ASSERT(mon.MainSize.x > 0.0f && mon.MainSize.y > 0.0f && "Monitor main bounds not setup properly.");
1105211052
IM_ASSERT(ImRect(mon.MainPos, mon.MainPos + mon.MainSize).Contains(ImRect(mon.WorkPos, mon.WorkPos + mon.WorkSize)) && "Monitor work bounds not setup properly. If you don't have work area information, just copy MainPos/MainSize into them.");
11053-
IM_ASSERT(mon.DpiScale != 0.0f);
11053+
IM_ASSERT(mon.DpiScale > 0.0f && mon.DpiScale < 99.0f && "Monitor DpiScale is invalid."); // Typical correct values would be between 1.0f and 4.0f
1105411054
}
1105511055
}
1105611056
}
@@ -15515,6 +15515,7 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view
1551515515
return;
1551615516
g.CurrentDpiScale = viewport ? viewport->DpiScale : 1.0f;
1551715517
g.CurrentViewport = viewport;
15518+
IM_ASSERT(g.CurrentDpiScale > 0.0f && g.CurrentDpiScale < 99.0f); // Typical correct values would be between 1.0f and 4.0f
1551815519
//IMGUI_DEBUG_LOG_VIEWPORT("[viewport] SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0);
1551915520

1552015521
// Notify platform layer of viewport changes
@@ -15793,6 +15794,7 @@ static void ImGui::UpdateViewportsNewFrame()
1579315794
new_dpi_scale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
1579415795
else
1579515796
new_dpi_scale = (viewport->DpiScale != 0.0f) ? viewport->DpiScale : 1.0f;
15797+
IM_ASSERT(new_dpi_scale > 0.0f && new_dpi_scale < 99.0f); // Typical correct values would be between 1.0f and 4.0f
1579615798
if (viewport->DpiScale != 0.0f && new_dpi_scale != viewport->DpiScale)
1579715799
{
1579815800
float scale_factor = new_dpi_scale / viewport->DpiScale;

0 commit comments

Comments
 (0)