From f95d015e5ece23a68325b285b650c89d542c9f53 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Thu, 20 Sep 2018 19:46:31 +0200 Subject: [PATCH] fix(wallet): dereference window after closing Dereference the main window after it has been closed in order to prevent messages from being set to it after it when it no longer exists. --- app/lib/zap/controller.js | 6 ++++++ app/main.dev.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/lib/zap/controller.js b/app/lib/zap/controller.js index f2f755b2..a7198f51 100644 --- a/app/lib/zap/controller.js +++ b/app/lib/zap/controller.js @@ -112,6 +112,12 @@ class ZapController { this.mainWindow.hide() } }) + + // Dereference the window object, usually you would store windows in an array if your app supports multi windows, + // this is the time when you should delete the corresponding element. + this.mainWindow.on('closed', () => { + this.mainWindow = null + }) } // ------------------------------------ diff --git a/app/main.dev.js b/app/main.dev.js index 69955f79..1dcbd737 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -109,7 +109,9 @@ app.on('ready', () => { event.preventDefault() zap.terminate() } else { - zap.mainWindow.forceClose = true + if (zap.mainWindow) { + zap.mainWindow.forceClose = true + } } })