fix(docking): improve root cleanup and simplify DockPanel cleanup logic

This commit is contained in:
2026-03-28 23:05:23 +09:00
parent c8f24edfd8
commit 0d8bc6f868
2 changed files with 13 additions and 11 deletions

View File

@@ -132,9 +132,17 @@ public abstract class DockContainer : DockModule
/// </summary> /// </summary>
protected virtual void CheckCleanup() protected virtual void CheckCleanup()
{ {
if (_children.Count == 0) if (Children.Count == 0)
{ {
Owner?.RemoveChildInternal(this, true); if (Owner != null)
{
Owner.RemoveChildInternal(this, true);
}
else if (Root != null && Root.RootModule == this)
{
Root.RootModule = null;
Root.NotifyLayoutEmpty();
}
} }
} }

View File

@@ -46,15 +46,9 @@ public class DockPanel : DockContainer
protected override void CheckCleanup() protected override void CheckCleanup()
{ {
if (Children.Count == 0)
{
if (Root != null && Root.RootModule == this)
{
Root.NotifyLayoutEmpty();
}
base.CheckCleanup(); base.CheckCleanup();
}
else if (Children.Count == 1) if (Children.Count == 1)
{ {
var child = Children[0]; var child = Children[0];
var owner = Owner; var owner = Owner;