Skip to content

Commit

Permalink
Asserting for invalid DpIScale values. (ocornut#8156)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Nov 18, 2024
1 parent 8082a84 commit d66f4e5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11050,7 +11050,7 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
IM_UNUSED(mon);
IM_ASSERT(mon.MainSize.x > 0.0f && mon.MainSize.y > 0.0f && "Monitor main bounds not setup properly.");
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.");
IM_ASSERT(mon.DpiScale != 0.0f);
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
}
}
}
Expand Down Expand Up @@ -15515,6 +15515,7 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view
return;
g.CurrentDpiScale = viewport ? viewport->DpiScale : 1.0f;
g.CurrentViewport = viewport;
IM_ASSERT(g.CurrentDpiScale > 0.0f && g.CurrentDpiScale < 99.0f); // Typical correct values would be between 1.0f and 4.0f
//IMGUI_DEBUG_LOG_VIEWPORT("[viewport] SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0);

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

0 comments on commit d66f4e5

Please sign in to comment.