From: SangYong Park Date: Wed, 3 Jul 2019 09:32:50 +0000 (+0900) Subject: Remove unnecessary event handling during termination X-Git-Tag: accepted/tizen/unified/20190814.021400~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f638eb86e7d404cab9d3dd3f2f130e2cf15d9e98;p=platform%2Fframework%2Fweb%2Fwrtjs.git Remove unnecessary event handling during termination Add code for preventing unnecessary event handling. and remove unusing code. Change-Id: I48ea7e9f6b36fe0eb0c19fb49a4ec4a10363e795 Signed-off-by: SangYong Park --- diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index 36e0eb1..ac408d2 100644 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -48,11 +48,12 @@ class Runtime { }, timeout, null); } } + _this.webApplication.finalize(); + _this.webApplication = null; }); app.on('will-quit', function(event) { console.log('will-quit'); _this.addonManager.deactivateAll(app); - _this.killAllProcesses(); }); app.on('quit', function(event) { console.log('quit'); @@ -173,20 +174,14 @@ class Runtime { }); wrt.on('suspend', function() { console.log('suspend'); - _this.webApplication.suspend(_this.addonManager.suspend_path); + if (_this.webApplication) + _this.webApplication.suspend(_this.addonManager.suspend_path); }); wrt.on('resume', function() { console.log('resume'); _this.webApplication.resume(_this.addonManager.resume_path); }); - wrt.on('terminate', function() { - console.log('terminate'); - _this.webApplication.terminate(); - }); } - onLanguageChanged() {} - onLowMemory() {} - killAllProcesses() {} handleIpcMessages() { var _this = this; ipcMain.on(IPC_MESSAGE.ADDONS.INSTALLED, (sender, name) => { diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js index 3b0f964..65aa1da 100755 --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -43,7 +43,6 @@ class WebApplication { } this.accessiblePath = wrt.getAccessiblePath(); this.isAlwaysReload = wrt.isAlwaysReload(); - this.isTerminating = false; this.suspended = true; this.loadFinished = false; this.runningStatus = 'none'; @@ -62,7 +61,7 @@ class WebApplication { console.log(`window closed : #${self.windowList.length}`); let index = self.windowList.indexOf(window); self.windowList.splice(index, 1); - if (!self.isTerminating && index === self.windowList.length && self.windowList.length > 0) + if (index === self.windowList.length && self.windowList.length > 0) self.windowList[self.windowList.length - 1].show(); }); }); @@ -256,11 +255,6 @@ class WebApplication { } } this.suspended = true; - if (this.isTerminating) { - console.log('App has been terminated; return'); - return; - } - let windows = WRTWindow.getAllWindows(); if (this.isTVProfile) { wrt.flushCookie(); this.windowList.forEach((window) => window.webContents.session.flushStorageData()); @@ -272,7 +266,7 @@ class WebApplication { app.quit(); }, 1000); } else if (!this.backgroundSupport) { - windows.forEach((window) => window.setEnabled(false)); + this.windowList.forEach((window) => window.setEnabled(false)); } this.windowList[this.windowList.length - 1].hide(); } @@ -293,14 +287,15 @@ class WebApplication { } return; } - WRTWindow.getAllWindows().forEach((window) => { - if (!this.backgroundSupport) - window.setEnabled(true); - }); + if (!this.backgroundSupport) { + this.windowList.forEach((window) => window.setEnabled(true)); + } this.windowList[this.windowList.length - 1].show(); } - terminate() { - this.isTerminating = true; + finalize() { + this.windowList.forEach((window) => { + window.removeAllListeners(); + }); } quit(path) { console.log('WebApplication : quit'); @@ -343,7 +338,7 @@ class WebApplication { } } closeWindows() { - WRTWindow.getAllWindows().forEach((window) => { + this.windowList.forEach((window) => { if (window != this.mainWindow) window.destroy(); });