Quellcode durchsuchen

Docking: fixed DockBuilderCopyDockSpace() crashing when windows not in the remapping list are docked on the left or top side of a split. (#6035)

ocornut vor 2 Jahren
Ursprung
Commit
6939676372
2 geänderte Dateien mit 9 neuen und 2 gelöschten Zeilen
  1. 2 0
      docs/CHANGELOG.txt
  2. 7 2
      imgui.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -146,6 +146,8 @@ Other changes:
 
 
 Docking+Viewports Branch:
 Docking+Viewports Branch:
 
 
+- Docking: Internals: fixed DockBuilderCopyDockSpace() crashing when windows not in the
+  remapping list are docked on the left or top side of a split. (#6035)
 - Backends: OSX: fixed typo in ImGui_ImplOSX_GetWindowSize that would cause issues when resiing
 - Backends: OSX: fixed typo in ImGui_ImplOSX_GetWindowSize that would cause issues when resiing
   from OS decorations, if they are enabled on secondary viewports. (#6009) [@sivu]
   from OS decorations, if they are enabled on secondary viewports. (#6009) [@sivu]
 
 

+ 7 - 2
imgui.cpp

@@ -17740,8 +17740,11 @@ void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_docks
         }
         }
     }
     }
 
 
-    // Anything else in the source nodes of 'node_remap_pairs' are windows that were docked in src_dockspace_id but are not owned by it (unaffiliated windows, e.g. "ImGui Demo")
+    // Anything else in the source nodes of 'node_remap_pairs' are windows that are not included in the remapping list.
     // Find those windows and move to them to the cloned dock node. This may be optional?
     // Find those windows and move to them to the cloned dock node. This may be optional?
+    // Dock those are a second step as undocking would invalidate source dock nodes.
+    struct DockRemainingWindowTask { ImGuiWindow* Window; ImGuiID DockId; DockRemainingWindowTask(ImGuiWindow* window, ImGuiID dock_id) { Window = window; DockId = dock_id; } };
+    ImVector<DockRemainingWindowTask> dock_remaining_windows;
     for (int dock_remap_n = 0; dock_remap_n < node_remap_pairs.Size; dock_remap_n += 2)
     for (int dock_remap_n = 0; dock_remap_n < node_remap_pairs.Size; dock_remap_n += 2)
         if (ImGuiID src_dock_id = node_remap_pairs[dock_remap_n])
         if (ImGuiID src_dock_id = node_remap_pairs[dock_remap_n])
         {
         {
@@ -17755,9 +17758,11 @@ void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_docks
 
 
                 // Docked windows gets redocked into the new node hierarchy.
                 // Docked windows gets redocked into the new node hierarchy.
                 IMGUI_DEBUG_LOG_DOCKING("[docking] Remap window '%s' %08X -> %08X\n", window->Name, src_dock_id, dst_dock_id);
                 IMGUI_DEBUG_LOG_DOCKING("[docking] Remap window '%s' %08X -> %08X\n", window->Name, src_dock_id, dst_dock_id);
-                DockBuilderDockWindow(window->Name, dst_dock_id);
+                dock_remaining_windows.push_back(DockRemainingWindowTask(window, dst_dock_id));
             }
             }
         }
         }
+    for (const DockRemainingWindowTask& task : dock_remaining_windows)
+        DockBuilderDockWindow(task.Window->Name, task.DockId);
 }
 }
 
 
 // FIXME-DOCK: This is awkward because in series of split user is likely to loose access to its root node.
 // FIXME-DOCK: This is awkward because in series of split user is likely to loose access to its root node.