From 506717390fa927024abe8cd7d52be94fac0a916a Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 16 Jun 2022 18:43:33 +0200 Subject: [PATCH] Docking, Modal: Fixed a crash when opening popup from a parent which is being docked on the same frame. (#5401) Ideally we should untangle the purpose of parent_window_in_stack / ParentWindowInBeginStack better. --- docs/CHANGELOG.txt | 1 + imgui.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index cb7ddadf..4fb87872 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -229,6 +229,7 @@ Docking+Viewports Branch: when io.ConfigDockingAlwaysTabBar is true. (#5324) [@rokups] - Docking: Fixed incorrect focus highlight on docking node when focusing empty central node or a child window which was manually injected into a dockspace window. +- Docking, Modal: Fixed a crash when opening popup from a parent which is being docked on the same frame. (#5401) - Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057) - Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize when multi-viewports are disabled. (#4900) diff --git a/imgui.cpp b/imgui.cpp index 179c9568..20793f14 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6464,7 +6464,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) } // Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack - ImGuiWindow* parent_window_in_stack = window->DockIsActive ? window->DockNode->HostWindow : g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back().Window; + ImGuiWindow* parent_window_in_stack = (window->DockIsActive && window->DockNode->HostWindow) ? window->DockNode->HostWindow : g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back().Window; ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow; IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow));