From: Surya Kumar Date: Thu, 4 May 2023 12:37:41 +0000 (+0530) Subject: Avoid "Object has been destroyed" JS error X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_6.0;p=platform%2Fframework%2Fweb%2Fwrtjs.git Avoid "Object has been destroyed" JS error It's possible mainWindow would be destroyed during suspend, but addonManager tries to access it without checking it leading to JS crash. This change fixes it. Change-Id: Ifbb65e13e290474b7628bc02ccac36a51f8bb367 Signed-off-by: Surya Kumar --- diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 9695eeb8..24bfff40 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -345,10 +345,11 @@ Then you can get profile log from the initial loading.`; if (this.suspended || this.inQuit) return; console.log('WebApplication : suspend'); - addonManager.emit('lcSuspend', this.mainWindow.id); this.suspended = true; - if (this.windowList.length > 0) + if (this.windowList.length > 0) { + addonManager.emit('lcSuspend', this.mainWindow.id); this.windowList[this.windowList.length - 1].hide(); + } this.flushData(); if (!this.backgroundRunnable()) { if (!this.multitaskingSupport) { @@ -376,7 +377,10 @@ Then you can get profile log from the initial loading.`; finalize() { console.log('WebApplication : finalize'); this.flushData(); - this.windowList.forEach((window) => window.removeAllListeners()); + this.windowList.forEach((window) => { + window.removeAllListeners(); + window.setEnabled(false); + }); this.inQuit = false; if (!this.suspended) this.suspend(); @@ -384,7 +388,8 @@ Then you can get profile log from the initial loading.`; quit() { console.log('WebApplication : quit'); - addonManager.emit('lcQuit', this.mainWindow.id); + if (this.windowList.length > 0) + addonManager.emit('lcQuit', this.mainWindow.id); if (wrt.tv) { this.inspectorSrc = ''; wrt.tv.cancelDialogs(this.mainWindow.webContents);