fix iOS crash when call Destory
This commit is contained in:
@@ -946,6 +946,7 @@ function NativeCall(target, propertyKey, descriptor) {
|
||||
}
|
||||
var Panel = /** @class */ (function () {
|
||||
function Panel() {
|
||||
this.destroyed = false;
|
||||
this.__root__ = new Root;
|
||||
this.headviews = new Map;
|
||||
this.onRenderFinishedCallback = [];
|
||||
@@ -1002,6 +1003,7 @@ var Panel = /** @class */ (function () {
|
||||
this.onCreate();
|
||||
};
|
||||
Panel.prototype.__onDestroy__ = function () {
|
||||
this.destroyed = true;
|
||||
this.onDestroy();
|
||||
};
|
||||
Panel.prototype.__onShow__ = function () {
|
||||
@@ -1101,6 +1103,9 @@ var Panel = /** @class */ (function () {
|
||||
Panel.prototype.hookAfterNativeCall = function () {
|
||||
var e_4, _a, e_5, _b;
|
||||
var _this = this;
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
var promises = [];
|
||||
if (Environment.platform !== 'web') {
|
||||
//Here insert a native call to ensure the promise is resolved done.
|
||||
|
@@ -701,6 +701,7 @@ function NativeCall(target, propertyKey, descriptor) {
|
||||
}
|
||||
class Panel {
|
||||
constructor() {
|
||||
this.destroyed = false;
|
||||
this.__root__ = new Root;
|
||||
this.headviews = new Map;
|
||||
this.onRenderFinishedCallback = [];
|
||||
@@ -757,6 +758,7 @@ class Panel {
|
||||
this.onCreate();
|
||||
}
|
||||
__onDestroy__() {
|
||||
this.destroyed = true;
|
||||
this.onDestroy();
|
||||
}
|
||||
__onShow__() {
|
||||
@@ -819,6 +821,9 @@ 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.
|
||||
|
@@ -2160,6 +2160,7 @@ function NativeCall(target, propertyKey, descriptor) {
|
||||
}
|
||||
class Panel {
|
||||
constructor() {
|
||||
this.destroyed = false;
|
||||
this.__root__ = new Root;
|
||||
this.headviews = new Map;
|
||||
this.onRenderFinishedCallback = [];
|
||||
@@ -2216,6 +2217,7 @@ class Panel {
|
||||
this.onCreate();
|
||||
}
|
||||
__onDestroy__() {
|
||||
this.destroyed = true;
|
||||
this.onDestroy();
|
||||
}
|
||||
__onShow__() {
|
||||
@@ -2278,6 +2280,9 @@ 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.
|
||||
|
1
doric-js/lib/src/ui/panel.d.ts
vendored
1
doric-js/lib/src/ui/panel.d.ts
vendored
@@ -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;
|
||||
|
@@ -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.
|
||||
|
@@ -33,6 +33,7 @@ type Frame = { width: number, height: number }
|
||||
declare function nativeEmpty(): void
|
||||
|
||||
export abstract class Panel {
|
||||
private destroyed = false
|
||||
context!: BridgeContext
|
||||
onCreate() { }
|
||||
onDestroy() { }
|
||||
@@ -103,6 +104,7 @@ export abstract class Panel {
|
||||
|
||||
@NativeCall
|
||||
private __onDestroy__() {
|
||||
this.destroyed = true
|
||||
this.onDestroy()
|
||||
}
|
||||
|
||||
@@ -175,6 +177,9 @@ export abstract class Panel {
|
||||
}
|
||||
|
||||
private hookAfterNativeCall() {
|
||||
if (this.destroyed) {
|
||||
return
|
||||
}
|
||||
const promises: Promise<any>[] = []
|
||||
if (Environment.platform !== 'web') {
|
||||
//Here insert a native call to ensure the promise is resolved done.
|
||||
|
Reference in New Issue
Block a user