From 1e924274b38f5460633fbb16cc1f6e6ceb497ff3 Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Wed, 9 May 2018 12:34:04 +0530 Subject: [PATCH] ELECTRON-455: fix memory leak on closing pop ups (#359) --- js/windowMgr.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/js/windowMgr.js b/js/windowMgr.js index 3cc70dc5..8f0bdfd9 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -395,21 +395,6 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) { browserWin.winName = frameName; browserWin.setAlwaysOnTop(alwaysOnTop); - let handleChildWindowClosed = () => { - removeWindowKey(newWinKey); - browserWin.removeListener('move', throttledBoundsChange); - browserWin.removeListener('resize', throttledBoundsChange); - }; - - browserWin.once('closed', () => { - handleChildWindowClosed(); - }); - - browserWin.on('close', () => { - browserWin.webContents.removeListener('new-window', handleNewWindow); - browserWin.webContents.removeListener('crashed', handleChildWindowCrashEvent); - }); - let handleChildWindowCrashEvent = (e) => { const options = { type: 'error', @@ -450,6 +435,21 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) { browserWin.on('move', throttledBoundsChange); browserWin.on('resize', throttledBoundsChange); + let handleChildWindowClosed = () => { + removeWindowKey(newWinKey); + browserWin.removeListener('move', throttledBoundsChange); + browserWin.removeListener('resize', throttledBoundsChange); + }; + + browserWin.on('close', () => { + browserWin.webContents.removeListener('new-window', handleNewWindow); + browserWin.webContents.removeListener('crashed', handleChildWindowCrashEvent); + }); + + browserWin.once('closed', () => { + handleChildWindowClosed(); + }); + handlePermissionRequests(browserWin.webContents); } });