fix(editor): ensure source container cleanup in ReplaceChild and document cross-layout moves
This commit is contained in:
@@ -40,6 +40,7 @@ public abstract class DockContainer : DockModule
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method does not support reordering existing children within the same container.
|
/// 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).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="index">The zero-based index at which the module should be inserted.</param>
|
/// <param name="index">The zero-based index at which the module should be inserted.</param>
|
||||||
/// <param name="module">The module to insert.</param>
|
/// <param name="module">The module to insert.</param>
|
||||||
@@ -90,6 +91,9 @@ public abstract class DockContainer : DockModule
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces an existing child module with a new one.
|
/// Replaces an existing child module with a new one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Cross-layout moves are intentionally allowed and supported (e.g., for dragging tabs between floating windows and the main window).
|
||||||
|
/// </remarks>
|
||||||
/// <param name="oldChild">The child module to be replaced.</param>
|
/// <param name="oldChild">The child module to be replaced.</param>
|
||||||
/// <param name="newChild">The new child module to insert.</param>
|
/// <param name="newChild">The new child module to insert.</param>
|
||||||
public virtual void ReplaceChild(DockModule oldChild, DockModule newChild)
|
public virtual void ReplaceChild(DockModule oldChild, DockModule newChild)
|
||||||
@@ -111,6 +115,7 @@ public abstract class DockContainer : DockModule
|
|||||||
throw new ArgumentException("newChild is already in this container", nameof(newChild));
|
throw new ArgumentException("newChild is already in this container", nameof(newChild));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldOwner = newChild.Owner;
|
||||||
newChild.Owner?.RemoveChildInternal(newChild, false);
|
newChild.Owner?.RemoveChildInternal(newChild, false);
|
||||||
|
|
||||||
// Remove oldChild without triggering cleanup
|
// Remove oldChild without triggering cleanup
|
||||||
@@ -131,6 +136,7 @@ public abstract class DockContainer : DockModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
CheckCleanup();
|
CheckCleanup();
|
||||||
|
oldOwner?.CheckCleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user