From 4e74c3731376179ff1b72305b982d0937e3415c6 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 14 Dec 2017 13:37:56 +0200 Subject: [PATCH] Fix android crash TabViewItem canBeLoaded was true even when TabView was destroyed Fix android crash modal view was not destroyed even though his dialog was --- tns-core-modules/ui/core/view/view.android.ts | 12 ++++++++---- tns-core-modules/ui/frame/frame-common.ts | 4 ---- tns-core-modules/ui/frame/frame.android.ts | 14 +++++--------- tns-core-modules/ui/tab-view/tab-view.android.ts | 5 +++++ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tns-core-modules/ui/core/view/view.android.ts b/tns-core-modules/ui/core/view/view.android.ts index d565450b3..285456b6b 100644 --- a/tns-core-modules/ui/core/view/view.android.ts +++ b/tns-core-modules/ui/core/view/view.android.ts @@ -187,13 +187,17 @@ function initializeDialogFragment() { super.onDismiss(dialog); const manager = this.getFragmentManager(); if (manager) { - const owner = this.owner; - removeModal(owner._domId); + removeModal(this.owner._domId); this._dismissCallback(); - owner._isAddedToNativeVisualTree = false; - owner._tearDownUI(true); } } + + public onDestroy(): void { + super.onDestroy(); + const owner = this.owner; + owner._isAddedToNativeVisualTree = false; + owner._tearDownUI(true); + } } DialogFragment = DialogFragmentImpl; diff --git a/tns-core-modules/ui/frame/frame-common.ts b/tns-core-modules/ui/frame/frame-common.ts index 15b9002a8..f7e4269f9 100644 --- a/tns-core-modules/ui/frame/frame-common.ts +++ b/tns-core-modules/ui/frame/frame-common.ts @@ -208,10 +208,6 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { return this._currentEntry === entry; } - public changeEntry(entry: BackstackEntry): void { - // android specific. - } - public setCurrent(entry: BackstackEntry, isBack: boolean): void { const newPage = entry.resolvedPage; // In case we navigated forward to a page that was in the backstack diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index ee392d85e..d7ca16e63 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -170,12 +170,6 @@ export class Frame extends FrameBase { return newFragment; } - public changeEntry(entry: BackstackEntry): void { - const isBack = this._isBack; - this.setCurrent(entry, isBack); - this._isBack = true; - } - public setCurrent(entry: BackstackEntry, isBack: boolean): void { const current = this._currentEntry; const currentEntryChanged = current !== entry; @@ -189,12 +183,10 @@ export class Frame extends FrameBase { if (this._tearDownPending) { this._tearDownPending = false; if (!entry.recreated) { - entry.recreated = false; clearEntry(entry); } - + if (current && !current.recreated) { - current.recreated = false; clearEntry(current); } @@ -205,6 +197,9 @@ export class Frame extends FrameBase { entry.fragment = this.createFragment(entry, entry.fragmentTag); entry.resolvedPage._setupUI(context); } + + entry.recreated = false; + current.recreated = false; } super.setCurrent(entry, isBack); @@ -402,6 +397,7 @@ function clearEntry(entry: BackstackEntry): void { _clearFragment(entry); } + entry.recreated = false; entry.fragment = null; const page = entry.resolvedPage; if (page._context) { diff --git a/tns-core-modules/ui/tab-view/tab-view.android.ts b/tns-core-modules/ui/tab-view/tab-view.android.ts index 857e5097e..9572b75c6 100644 --- a/tns-core-modules/ui/tab-view/tab-view.android.ts +++ b/tns-core-modules/ui/tab-view/tab-view.android.ts @@ -261,6 +261,11 @@ export class TabViewItem extends TabViewItemBase { } } + public disposeNativeView(): void { + super.disposeNativeView(); + (this).canBeLoaded = false; + } + public createNativeView() { return this.nativeViewProtected; }