Skip to content

Commit

Permalink
Viewports: fix window with viewport ini data immediately merged into …
Browse files Browse the repository at this point in the history
…a host viewport from leaving a temporary viewport alive for a frame (would leak into backend).
  • Loading branch information
ocornut committed Sep 10, 2021
1 parent 6b77668 commit 79d39b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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).


-----------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 79d39b1

Please sign in to comment.