From 1c553a55fa26d159f75ca8a5a6020868d871941c Mon Sep 17 00:00:00 2001 From: Misaki Date: Sat, 28 Mar 2026 23:10:46 +0900 Subject: [PATCH] fix(editor): ensure source container cleanup in ReplaceChild and document cross-layout moves --- .../Ghost.Editor/View/Controls/Docking/DockContainer.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockContainer.cs b/src/Editor/Ghost.Editor/View/Controls/Docking/DockContainer.cs index cbaffca..20cb5cb 100644 --- a/src/Editor/Ghost.Editor/View/Controls/Docking/DockContainer.cs +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockContainer.cs @@ -40,6 +40,7 @@ public abstract class DockContainer : DockModule /// /// /// This method does not support reordering existing children within the same container. + /// Cross-layout moves are intentionally allowed and supported (e.g., for dragging tabs between floating windows and the main window). /// /// The zero-based index at which the module should be inserted. /// The module to insert. @@ -90,6 +91,9 @@ public abstract class DockContainer : DockModule /// /// Replaces an existing child module with a new one. /// + /// + /// Cross-layout moves are intentionally allowed and supported (e.g., for dragging tabs between floating windows and the main window). + /// /// The child module to be replaced. /// The new child module to insert. public virtual void ReplaceChild(DockModule oldChild, DockModule newChild) @@ -110,7 +114,8 @@ public abstract class DockContainer : DockModule { throw new ArgumentException("newChild is already in this container", nameof(newChild)); } - + + var oldOwner = newChild.Owner; newChild.Owner?.RemoveChildInternal(newChild, false); // Remove oldChild without triggering cleanup @@ -131,6 +136,7 @@ public abstract class DockContainer : DockModule } CheckCleanup(); + oldOwner?.CheckCleanup(); } ///