From 1ae0a1e65800167dd7cdcb536b183c67b3ab3953 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 30 Sep 2018 19:34:03 +0200 Subject: [PATCH] Docking: Fix DockContextRebuild() temporarily invalidating dockid reference leading to undesirable merging of nodes. --- imgui.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 7eb02cd5c..4a2d8a00e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9634,11 +9634,11 @@ namespace ImGui static void DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer); static void DockContextQueueNotifyRemovedNode(ImGuiContext* ctx, ImGuiDockNode* node); static void DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req); - static void DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window); + static void DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref = true); static void DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node); static void DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx); static ImGuiDockNode* DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id); - static void DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_persistent_docking_references); // Set root_id==0 to clear all + static void DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_persistent_docking_refs); // Set root_id==0 to clear all static void DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDockNodeSettings* node_settings_array, int node_settings_count); static void DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id); // Use root_id==0 to add all @@ -10129,11 +10129,11 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) MarkIniSettingsDirty(); } -void ImGui::DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window) +void ImGui::DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref) { (void)ctx; if (window->DockNode) - DockNodeRemoveWindow(window->DockNode, window, 0); + DockNodeRemoveWindow(window->DockNode, window, clear_persistent_docking_ref ? 0 : window->DockId); else window->DockId = 0; window->Collapsed = false; @@ -11671,10 +11671,10 @@ void ImGui::DockBuilderRemoveNodeDockedWindows(ImGuiContext* ctx, ImGuiID root_i bool want_removal = (root_id == 0) || (window->DockNode && DockNodeGetRootNode(window->DockNode)->ID == root_id) || (window->DockNodeAsHost && window->DockNodeAsHost->ID == root_id); if (want_removal) { - ImGuiID backup_dock_id = window->DockId; - DockContextProcessUndockWindow(ctx, window); + const ImGuiID backup_dock_id = window->DockId; + DockContextProcessUndockWindow(ctx, window, clear_persistent_docking_references); if (!clear_persistent_docking_references) - window->DockId = backup_dock_id; + IM_ASSERT(window->DockId == backup_dock_id); } } }