FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(modal): Fix crash if modal is destroyed before dismissed in Andro… · NativeScript/NativeScript@8a32102 · GitHub

Commit 8a32102

Browse files
Alexander Vakrilov
authored
fix(modal): Fix crash if modal is destroyed before dismissed in Android (#6723)
1 parent 36f289b commit 8a32102

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎tns-core-modules/ui/core/view/view.android.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,17 @@ function initializeDialogFragment() {
195195
public onDestroy(): void {
196196
super.onDestroy();
197197
const owner = this.owner;
198-
owner._isAddedToNativeVisualTree = false;
199-
owner._tearDownUI(true);
198+
199+
if (owner) {
200+
// Android calls onDestroy before onDismiss.
201+
// Make sure we unload first and then call _tearDownUI.
202+
if (owner.isLoaded) {
203+
owner.callUnloaded();
204+
}
205+
206+
owner._isAddedToNativeVisualTree = false;
207+
owner._tearDownUI(true);
208+
}
200209
}
201210
}
202211

@@ -386,7 +395,7 @@ export class View extends ViewCommon {
386395
if (!this.nativeViewProtected || !this.hasGestureObservers()) {
387396
return;
388397
}
389-
398+
390399
// do not set noop listener that handles the event (disabled listener) if IsUserInteractionEnabled is
391400
// false as we might need the ability for the event to pass through to a parent view
392401
initializeTouchListener();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL