From 0abe7d1cc50dfc63b1f4da69dcc9270aaef62e1f Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Aug 2022 16:11:39 +0200 Subject: [PATCH] Docking: Fixed splitting/docking into a node that has buttons amended into tab bar. Windows were not moved correctly. (#5515) --- imgui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index d2858a983a51..ad8aaf722878 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -14738,10 +14738,14 @@ static void ImGui::DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* s src_node->TabBar = NULL; } - for (int n = 0; n < src_node->Windows.Size; n++) + for (int n_from_node = 0, n_from_tab_bar = 0; n_from_node < src_node->Windows.Size; n_from_node++, n_from_tab_bar++) { // DockNode's TabBar may have non-window Tabs manually appended by user - if (ImGuiWindow* window = src_tab_bar ? src_tab_bar->Tabs[n].Window : src_node->Windows[n]) + while (src_tab_bar && src_tab_bar->Tabs[n_from_tab_bar].Window == NULL) + n_from_tab_bar++; + + // Using TabBar order (FIXME: Why? Clarify + add tests for it) + if (ImGuiWindow* window = src_tab_bar ? src_tab_bar->Tabs[n_from_tab_bar].Window : src_node->Windows[n_from_node]) { window->DockNode = NULL; window->DockIsActive = false;