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];