Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(navigationbar): Avoid NSObject_Disposer:Drain with custom NavigationBar content #958

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ internal partial class TitleView : Border

internal event EventHandler? ParentChanged;

#pragma warning disable IDE0052 // Remove unread private members
private UIView? _superView;
kazo0 marked this conversation as resolved.
Show resolved Hide resolved
#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 @@ -235,6 +239,12 @@ public override void SetSuperviewNeedsLayout()
// so we can restore the NavigationBar parent that can propagate the DataContext
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();

ParentChanged?.Invoke(this, EventArgs.Empty);
Expand Down
Loading