Skip to content

Commit

Permalink
Null terminate Page on TabbedRenderer (dotnet#23290)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
  • Loading branch information
github-actions[bot] and PureWeen committed Jun 27, 2024
1 parent 45a8686 commit 51ad8f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)

public override void ViewDidAppear(bool animated)
{
Page.SendAppearing();
Page?.SendAppearing();
base.ViewDidAppear(animated);
}

public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
Page.SendDisappearing();
Page?.SendDisappearing();
}

public override void ViewDidLayoutSubviews()
Expand Down Expand Up @@ -158,7 +158,7 @@ protected virtual void OnElementChanged(VisualElementChangedEventArgs e)

UIViewController GetViewController(Page page)
{
if (page.Handler is not IPlatformViewHandler nvh)
if (page?.Handler is not IPlatformViewHandler nvh)
return null;

return nvh.ViewController;
Expand Down
12 changes: 10 additions & 2 deletions src/TestUtils/src/DeviceTests/AssertionExtensions.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,16 @@ public static async Task<T> AttachAndRun<T>(this AView view, Func<Task<T>> actio
}
finally
{
rootView.RemoveView(layout);
layout.RemoveView(view);
if (rootView.IsAlive() && layout.IsAlive())
{
rootView.RemoveView(layout);
}

if (layout.IsAlive() && view.IsAlive())
{
layout.RemoveView(view);
}

_attachAndRunSemaphore.Release();
}
}
Expand Down

0 comments on commit 51ad8f6

Please sign in to comment.