From f48ca97b6ca18987c4d91f77376d189f2b1ac652 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Fri, 6 Mar 2020 15:49:32 +0100 Subject: [PATCH] Correctly release SendTabDialog in onDestroy (#2928) --- .../mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java | 7 ++++++- .../org/mozilla/vrbrowser/ui/widgets/TabsWidget.java | 4 ++++ .../shared/org/mozilla/vrbrowser/ui/widgets/Windows.java | 4 ++++ .../org/mozilla/vrbrowser/ui/widgets/dialogs/UIDialog.java | 4 +++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java index 922fa85e9..15974848f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java @@ -374,8 +374,13 @@ public void releaseWidget() { } detachFromWindow(); - mAttachedWindow = null; + + if (mSendTabDialog != null && !mSendTabDialog.isReleased()) { + mSendTabDialog.releaseWidget(); + } + mSendTabDialog = null; + super.releaseWidget(); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TabsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TabsWidget.java index 8fd892095..5e3a24913 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TabsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TabsWidget.java @@ -159,6 +159,10 @@ public void attachToWindow(WindowWidget aWindow) { @Override public void releaseWidget() { + if (mSendTabDialog != null && !mSendTabDialog.isReleased()) { + mSendTabDialog.releaseWidget(); + } + mSendTabDialog = null; super.releaseWidget(); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java index ee025fa22..06cc74768 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java @@ -459,6 +459,10 @@ public void onResume() { } public void onDestroy() { + if (mTabsWidget != null && !mTabsWidget.isReleased()) { + mTabsWidget.releaseWidget(); + mTabsWidget = null; + } mDelegate = null; for (WindowWidget window: mRegularWindows) { window.close(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/UIDialog.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/UIDialog.java index e7a50f9f5..d7c73caf0 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/UIDialog.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/UIDialog.java @@ -33,7 +33,9 @@ private void initialize() { @Override public void releaseWidget() { - mWidgetManager.removeWorldClickListener(this); + if (mWidgetManager != null) { + mWidgetManager.removeWorldClickListener(this); + } mDialogs.remove(this); super.releaseWidget(); }