Skip to content

Commit

Permalink
fix(commandbar): Avoid NSObject_Disposer:Drain with custom AppBar con…
Browse files Browse the repository at this point in the history
…tent
  • Loading branch information
jeromelaban committed Dec 5, 2023
1 parent 8b3b3e9 commit d48ddf3
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ internal partial class TitleView : Border
private Size _childSize;
private Size? _lastAvailableSize;

#pragma warning disable IDE0052 // Remove unread private members
private UIView? _superView;
#pragma warning restore IDE0052 // Remove unread private members

public override void SetSuperviewNeedsLayout()
{
// Skip the base invocation because the base fetches the native parent
Expand All @@ -172,6 +176,17 @@ public override void SetSuperviewNeedsLayout()
// See https://github.com/unoplatform/uno/issues/7012 for more details.
}

public override void MovedToSuperview()
{
// Store an explicit reference to the superview in order to avoid
// generic access from the framework element infrastructure.
// This will avoid the superview from being natively released
// while this view may still try to use it and corrupt the heap, then
// cause NSObject_Disposer:Drain to fail randomly.
_superView = Superview;
base.MovedToSuperview();
}

internal TitleView()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
Expand Down

0 comments on commit d48ddf3

Please sign in to comment.