From 7f3f3891c04d36dfa5ea86db975863e46c48cd8a Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 17 May 2015 22:15:40 +0100 Subject: [PATCH] WIP Menus: fixed case where zero-sized display (e.g. minimised window) clips popups/menus and asserted (#126) --- imgui.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index a2510c9d..b3dcda0d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3062,11 +3062,13 @@ static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags) ImFormatString(name, 20, "##popup_%08x", id); // Not recycling, so we can close/open during the same frame float alpha = 1.0f; bool opened = ImGui::Begin(name, NULL, ImVec2(0.0f, 0.0f), alpha, flags); - IM_ASSERT(opened); if (!(window->Flags & ImGuiWindowFlags_ShowBorders)) GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders; + if (!opened) // opened can be 'false' when the popup is completely clipped (e.g. zero size display) + ImGui::EndPopup(); + return opened; } @@ -7518,8 +7520,7 @@ bool ImGui::BeginMenu(const char* label) if (opened) { ImGui::SetNextWindowPos(popup_pos, ImGuiSetCond_Always); - bool popup_opened = BeginPopupEx(label, ImGuiWindowFlags_Menu); - IM_ASSERT(opened == popup_opened); + opened = BeginPopupEx(label, ImGuiWindowFlags_Menu); // opened can be 'false' when the popup is completely clipped (e.g. zero size display) } return opened;