From ff7ca9f52cacf773256a714d884848dde9e0641a Mon Sep 17 00:00:00 2001 From: liwei Date: Mon, 15 Mar 2021 13:58:07 +0800 Subject: [PATCH] Minor refactor logic of quit for non-multitasking app 1.If app run in background and not support multitasking, app will quit immediatly, window will be desotried, then exception will happen, so ahead timing of addon event to avid window is null, ahead timing of addon event contentDidFinishLoad. 2.Set timeout to 0 for app.quit(), then it will be a little delay, it can avoid crash. Change-Id: I8c0cc11f13c48384e5a3e1965a1fc27353e81a3a Signed-off-by: liwei --- wrt_app/src/web_application.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 6afc4ac..9d782c7 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -278,6 +278,7 @@ export class WebApplication { console.log('webContents did-finish-load'); this.loadFinished = true; wrt.hideSplashScreen(1); + addonManager.emit('contentDidFinishLoad', this.mainWindow.id); if (wrt.isIMEWebApp()) { this.activateIMEWebHelperClient(); } else if (wrt.tv) { @@ -286,7 +287,6 @@ export class WebApplication { else this.suspendByStatus(); } - addonManager.emit('contentDidFinishLoad', this.mainWindow.id); }); } @@ -411,13 +411,12 @@ Then you can get profile log from the initial loading.`; this.suspended = true; this.windowList[this.windowList.length - 1].hide(); this.flushData(); - if (!this.backgroundRunnable()) { - if (!this.multitaskingSupport) { + this.windowList.forEach((window) => window.setEnabled(false)); + if (!this.backgroundRunnable() && !this.multitaskingSupport) { + setTimeout(() => { console.log('multitasking is not supported; quitting app') app.quit(); - } else { - this.windowList.forEach((window) => window.setEnabled(false)); - } + }, 0); } } -- 2.7.4