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).

This commit is contained in:
ocornut 2021-09-10 14:58:45 +02:00
parent 6b77668171
commit 79d39b190b
2 changed files with 7 additions and 0 deletions

View File

@ -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).
-----------------------------------------------------------------------

View File

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