From 1ca6ff974ccc0359cd58925fd9635fe1d028d5c6 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 17 Sep 2019 18:02:58 +0200 Subject: [PATCH] Viewport: fix to allow multiple shutdown / calls to DestroyPlatformWindows(). (#2769) --- imgui.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 70914d2bc942..5048bc5b2657 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11173,7 +11173,11 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) if (g.PlatformIO.Platform_DestroyWindow) g.PlatformIO.Platform_DestroyWindow(viewport); IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL); - viewport->PlatformWindowCreated = false; + + // Don't clear PlatformWindowCreated for the main viewport, as we initially set that up to true in Initialize() + // The right-er way may be to leave it to the back-end to set this flag all-together, and made the flag public. + if (viewport->ID != IMGUI_VIEWPORT_DEFAULT_ID) + viewport->PlatformWindowCreated = false; } else {