mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix: Page and Frame isLoaded undefined checks (#6255)
* fix(view): isLoaded handling closes https://github.com/NativeScript/NativeScript/issues/6179 * refactor: Error handling code in onCreateView
This commit is contained in:

committed by
vakrilov

parent
8575c60b13
commit
12fade7155
@ -595,13 +595,13 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
|||||||
}
|
}
|
||||||
|
|
||||||
public loadView(view: ViewBase): void {
|
public loadView(view: ViewBase): void {
|
||||||
if (!view.isLoaded) {
|
if (view && !view.isLoaded) {
|
||||||
view.callLoaded();
|
view.callLoaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unloadView(view: ViewBase): void {
|
public unloadView(view: ViewBase): void {
|
||||||
if (view.isLoaded) {
|
if (view && view.isLoaded) {
|
||||||
view.callUnloaded();
|
view.callUnloaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ function initializeDialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const owner = this.owner;
|
const owner = this.owner;
|
||||||
if (!owner.isLoaded) {
|
if (owner && !owner.isLoaded) {
|
||||||
owner.callLoaded();
|
owner.callLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ function initializeDialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const owner = this.owner;
|
const owner = this.owner;
|
||||||
if (owner.isLoaded) {
|
if (owner && owner.isLoaded) {
|
||||||
owner.callUnloaded();
|
owner.callUnloaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import { Page } from "../page";
|
|||||||
import * as application from "../../application";
|
import * as application from "../../application";
|
||||||
import {
|
import {
|
||||||
FrameBase, stack, goBack, View, Observable,
|
FrameBase, stack, goBack, View, Observable,
|
||||||
traceEnabled, traceWrite, traceCategories
|
traceEnabled, traceWrite, traceCategories, traceError
|
||||||
} from "./frame-common";
|
} from "./frame-common";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -696,8 +696,23 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const entry = this.entry;
|
const entry = this.entry;
|
||||||
|
if (!entry) {
|
||||||
|
traceError(`${fragment}.onCreateView: entry is null or undefined`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const page = entry.resolvedPage;
|
const page = entry.resolvedPage;
|
||||||
|
if (!page) {
|
||||||
|
traceError(`${fragment}.onCreateView: entry has no resolvedPage`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const frame = this.frame;
|
const frame = this.frame;
|
||||||
|
if (!frame) {
|
||||||
|
traceError(`${fragment}.onCreateView: this.frame is null or undefined`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (page.parent === frame) {
|
if (page.parent === frame) {
|
||||||
// If we are navigating to a page that was destroyed
|
// If we are navigating to a page that was destroyed
|
||||||
// reinitialize its UI.
|
// reinitialize its UI.
|
||||||
@ -706,12 +721,12 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
|||||||
page._setupUI(context);
|
page._setupUI(context);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!this.frame._styleScope) {
|
if (!frame._styleScope) {
|
||||||
// Make sure page will have styleScope even if parents don't.
|
// Make sure page will have styleScope even if parents don't.
|
||||||
page._updateStyleScope();
|
page._updateStyleScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.frame._addView(page);
|
frame._addView(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame.isLoaded && !page.isLoaded) {
|
if (frame.isLoaded && !page.isLoaded) {
|
||||||
|
@ -357,7 +357,7 @@ export class CssState {
|
|||||||
* As a result, at some point in time, the selectors matched have to be requerried from the style scope and applied to the view.
|
* As a result, at some point in time, the selectors matched have to be requerried from the style scope and applied to the view.
|
||||||
*/
|
*/
|
||||||
public onChange(): void {
|
public onChange(): void {
|
||||||
if (this.view.isLoaded) {
|
if (this.view && this.view.isLoaded) {
|
||||||
this.unsubscribeFromDynamicUpdates();
|
this.unsubscribeFromDynamicUpdates();
|
||||||
this.updateMatch();
|
this.updateMatch();
|
||||||
this.subscribeForDynamicUpdates();
|
this.subscribeForDynamicUpdates();
|
||||||
|
Reference in New Issue
Block a user