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

fix: Page and Frame isLoaded undefined checks (#6255) · NativeScript/NativeScript@12fade7 · GitHub

Commit 12fade7

Browse files
Alexander Vakrilov
committed
fix: Page and Frame isLoaded undefined checks (#6255)
* fix(view): isLoaded handling closes #6179 * refactor: Error handling code in onCreateView
1 parent 8575c60 commit 12fade7

4 files changed

Lines changed: 23 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,13 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
595595
}
596596

597597
public loadView(view: ViewBase): void {
598-
if (!view.isLoaded) {
598+
if (view && !view.isLoaded) {
599599
view.callLoaded();
600600
}
601601
}
602602

603603
public unloadView(view: ViewBase): void {
604-
if (view.isLoaded) {
604+
if (view && view.isLoaded) {
605605
view.callUnloaded();
606606
}
607607
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function initializeDialogFragment() {
180180
}
181181

182182
const owner = this.owner;
183-
if (!owner.isLoaded) {
183+
if (owner && !owner.isLoaded) {
184184
owner.callLoaded();
185185
}
186186

@@ -196,7 +196,7 @@ function initializeDialogFragment() {
196196
}
197197

198198
const owner = this.owner;
199-
if (owner.isLoaded) {
199+
if (owner && owner.isLoaded) {
200200
owner.callUnloaded();
201201
}
202202
}

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Page } from "../page";
99
import * as application from "../../application";
1010
import {
1111
FrameBase, stack, goBack, View, Observable,
12-
traceEnabled, traceWrite, traceCategories
12+
traceEnabled, traceWrite, traceCategories, traceError
1313
} from "./frame-common";
1414

1515
import {
@@ -696,8 +696,23 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
696696
}
697697

698698
const entry = this.entry;
699+
if (!entry) {
700+
traceError(`${fragment}.onCreateView: entry is null or undefined`);
701+
return null;
702+
}
703+
699704
const page = entry.resolvedPage;
705+
if (!page) {
706+
traceError(`${fragment}.onCreateView: entry has no resolvedPage`);
707+
return null;
708+
}
709+
700710
const frame = this.frame;
711+
if (!frame) {
712+
traceError(`${fragment}.onCreateView: this.frame is null or undefined`);
713+
return null;
714+
}
715+
701716
if (page.parent === frame) {
702717
// If we are navigating to a page that was destroyed
703718
// reinitialize its UI.
@@ -706,12 +721,12 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
706721
page._setupUI(context);
707722
}
708723
} else {
709-
if (!this.frame._styleScope) {
724+
if (!frame._styleScope) {
710725
// Make sure page will have styleScope even if parents don't.
711726
page._updateStyleScope();
712727
}
713728

714-
this.frame._addView(page);
729+
frame._addView(page);
715730
}
716731

717732
if (frame.isLoaded && !page.isLoaded) {

‎tns-core-modules/ui/styling/style-scope.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class CssState {
357357
* As a result, at some point in time, the selectors matched have to be requerried from the style scope and applied to the view.
358358
*/
359359
public onChange(): void {
360-
if (this.view.isLoaded) {
360+
if (this.view && this.view.isLoaded) {
361361
this.unsubscribeFromDynamicUpdates();
362362
this.updateMatch();
363363
this.subscribeForDynamicUpdates();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL