Skip to content

Commit 7ca793f

Browse files
emmaussmaxkatz6
authored andcommitted
dispose layout manager when embeddable control root is disposed. (#14341)
1 parent 44821ad commit 7ca793f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Android/Avalonia.Android/AvaloniaView.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public object Content
4141
set { _root.Content = value; }
4242
}
4343

44+
protected override void Dispose(bool disposing)
45+
{
46+
base.Dispose(disposing);
47+
_root?.Dispose();
48+
_root = null;
49+
}
50+
4451
public override bool DispatchKeyEvent(KeyEvent e)
4552
{
4653
return _view.View.DispatchKeyEvent(e);

src/Android/Avalonia.Android/SingleViewLifetime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public SingleViewLifetime(Activity activity)
1515
_activity = activity;
1616

1717
if (activity is IAvaloniaActivity activableActivity)
18-
{
18+
{
1919
activableActivity.Activated += (_, args) => Activated?.Invoke(this, args);
2020
activableActivity.Deactivated += (_, args) => Deactivated?.Invoke(this, args);
2121
}

src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ protected override Size MeasureOverride(Size availableSize)
5151
}
5252

5353
protected override Type StyleKeyOverride => typeof(EmbeddableControlRoot);
54-
public void Dispose() => PlatformImpl?.Dispose();
54+
55+
public void Dispose()
56+
{
57+
PlatformImpl?.Dispose();
58+
LayoutManager?.Dispose();
59+
}
5560
}
5661
}

0 commit comments

Comments
 (0)