From f62edda184d65f902c5801528ed7c082d0b90556 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 23 Jun 2021 11:21:55 +0900 Subject: [PATCH] Fix an error of 'Object has been destroyed' When app is terminate by SIGTERM or tizen.application...exit(), There comes a TypeError 'Object has been destroyed' suspend() will be called again on quit() for backgroun-runnable apps, but since this.mainWindow can be already destroyed, below code can throw exception with destroyed object 'this.mainWindow' - addonManager.emit('lcSuspend', this.mainWindow.id); It is enough to call setEnable() for suspending (if window is alive) Change-Id: Ie2e99cf74ca412902e4456901dc8350f038e3067 Signed-off-by: DongHyun Song --- wrt_app/src/web_application.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 53e0899..84be283 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -283,10 +283,11 @@ export class WebApplication { 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.profileDelegate.canIgnoreSuspend()) return; @@ -318,10 +319,11 @@ export class WebApplication { quit() { console.log('WebApplication : quit'); 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(); } beforeQuit() { -- 2.7.4