fix iOS crash when call Destory

This commit is contained in:
pengfei.zhou
2020-05-06 17:34:48 +08:00
committed by osborn
parent c9c99cce06
commit 7828b24cd5
12 changed files with 43 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import { Root } from '../widget/layouts';
import { BridgeContext } from '../runtime/global';
export declare function NativeCall(target: Panel, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
export declare abstract class Panel {
private destroyed;
context: BridgeContext;
onCreate(): void;
onDestroy(): void;

View File

@@ -35,6 +35,7 @@ export function NativeCall(target, propertyKey, descriptor) {
}
export class Panel {
constructor() {
this.destroyed = false;
this.__root__ = new Root;
this.headviews = new Map;
this.onRenderFinishedCallback = [];
@@ -91,6 +92,7 @@ export class Panel {
this.onCreate();
}
__onDestroy__() {
this.destroyed = true;
this.onDestroy();
}
__onShow__() {
@@ -153,6 +155,9 @@ export class Panel {
}
}
hookAfterNativeCall() {
if (this.destroyed) {
return;
}
const promises = [];
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.