Error Handling: added better report and recovery for extraneous EndPopup() call. (#1651, #8499)

This commit is contained in:
ocornut
2025-03-18 17:35:43 +01:00
parent f5befd2d29
commit 5679de60c5
2 changed files with 17 additions and 2 deletions

View File

@@ -11818,8 +11818,11 @@ void ImGui::EndPopup()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
IM_ASSERT(g.BeginPopupStack.Size > 0);
if ((window->Flags & ImGuiWindowFlags_Popup) == 0 || g.BeginPopupStack.Size == 0)
{
IM_ASSERT_USER_ERROR(0, "Calling EndPopup() too many times or in wrong window!");
return;
}
// Make all menus and popups wrap around for now, may need to expose that policy (e.g. focus scope could include wrap/loop policy flags used by new move requests)
if (g.NavWindow == window)