зеркало из https://github.com/DeGsoft/maui-linux.git
[Android] Add disposed check to MasterDetailPageRenderer (#6354)
* [Android] Add disposed check to MasterDetailPageRenderer Co-Authored-By: Felipe Silveira <transis2@users.noreply.github.com> * Fix dispose pattern a la #6305 * apply same set of changes to NavigationPageRenderer fixes #3489 closes #4586
This commit is contained in:
Родитель
47a25dc714
Коммит
0c6e2c957b
|
@ -207,10 +207,13 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && !_disposed)
|
||||
{
|
||||
_disposed = true;
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
_disposed = true;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
if (_tracker != null)
|
||||
{
|
||||
_tracker.Dispose();
|
||||
|
@ -236,7 +239,8 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
|
||||
Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;
|
||||
|
||||
RemoveDrawerListener(this);
|
||||
if (!this.IsDisposed())
|
||||
RemoveDrawerListener(this);
|
||||
|
||||
if (Element != null)
|
||||
{
|
||||
|
|
|
@ -161,10 +161,13 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && !_disposed)
|
||||
{
|
||||
_disposed = true;
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
_disposed = true;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
if (_titleViewRenderer != null)
|
||||
{
|
||||
Android.Platform.ClearRenderer(_titleViewRenderer.View);
|
||||
|
@ -196,7 +199,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
_toolbar = null;
|
||||
}
|
||||
|
||||
if (_drawerLayout != null && _drawerListener != null)
|
||||
if (_drawerLayout.IsAlive() && _drawerListener.IsAlive())
|
||||
{
|
||||
_drawerLayout.RemoveDrawerListener(_drawerListener);
|
||||
}
|
||||
|
|
|
@ -8,5 +8,12 @@ namespace Xamarin.Forms.Platform.Android
|
|||
{
|
||||
return obj.Handle == IntPtr.Zero;
|
||||
}
|
||||
public static bool IsAlive(this Java.Lang.Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
return !obj.IsDisposed();
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче