From 79d39b190b9266a6c6e7fb72196323cd6c753868 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 10 Sep 2021 14:58:45 +0200 Subject: [PATCH] Viewports: fix window with viewport ini data immediately merged into a host viewport from leaving a temporary viewport alive for a frame (would leak into backend). --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 3cd090e6..807f3c25 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -152,6 +152,8 @@ Docking+Viewports Branch: It would manifest when e.g. reconfiguring dock nodes while dragging. - Viewports: Fixed unnecessary creation of temporary viewports when multiple docked windows got reassigned to a new node (created mid-frame) which already has a HostWindow. +- Viewports: Fixed window with viewport ini data immediately merged into a host viewport from + leaving a temporary viewport alive for a frame (would leak into backend). ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index edbc0a15..5e39be10 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11574,6 +11574,10 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view static void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport) { + // Abandon viewport + if (window->ViewportOwned && window->Viewport->Window == window) + window->Viewport->Size = ImVec2(0.0f, 0.0f); + window->Viewport = viewport; window->ViewportId = viewport->ID; window->ViewportOwned = (viewport->Window == window); @@ -11606,6 +11610,7 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG if (GetWindowAlwaysWantOwnViewport(window)) return false; + // FIXME: Can't use g.WindowsFocusOrder[] for root windows only as we care about Z order. If we maintained a DisplayOrder along with FocusOrder we could.. for (int n = 0; n < g.Windows.Size; n++) { ImGuiWindow* window_behind = g.Windows[n];