From 515ecbddc270f3129642e9f1ab8d95e3778a0b95 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 3 Jan 2019 23:02:40 +0100 Subject: [PATCH] Docking: Fix for handling of orphan/inactive dock node with ConfigDockingTabBarOnSingleWindows (would crash). --- imgui.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index dc47c459..fc766205 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5299,6 +5299,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Position child window if (flags & ImGuiWindowFlags_ChildWindow) { + IM_ASSERT(parent_window->Active); window->BeginOrderWithinParent = (short)parent_window->DC.ChildWindows.Size; parent_window->DC.ChildWindows.push_back(window); if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip) @@ -12517,7 +12518,11 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) // Create node if (dock_node == NULL) + { dock_node = DockContextAddNode(ctx, window->DockId); + if (auto_dock_node) + dock_node->LastFrameAlive = g.FrameCount; + } DockNodeAddWindow(dock_node, window, true); IM_ASSERT(dock_node == window->DockNode); @@ -12538,7 +12543,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) // Undock if our dockspace node disappeared // Note how we are testing for LastFrameAlive and NOT LastFrameActive. A DockSpace node can be maintained alive while being inactive with ImGuiDockNodeFlags_KeepAliveOnly. - if (dock_node->LastFrameAlive < g.FrameCount && !auto_dock_node) + if (dock_node->LastFrameAlive < g.FrameCount) { // If the window has been orphaned, transition the docknode to an implicit node processed in DockContextUpdateDocking() ImGuiDockNode* root_node = DockNodeGetRootNode(dock_node);