From d7a11fe50c76471cea7050b1f7f5f38d91d5bb44 Mon Sep 17 00:00:00 2001 From: bridiver Date: Fri, 11 Dec 2015 17:43:10 -0700 Subject: [PATCH] don't crash on tab or window close when no windows are active --- app/menu.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/menu.js b/app/menu.js index 99eff0a63d2..73bf3068246 100644 --- a/app/menu.js +++ b/app/menu.js @@ -30,14 +30,24 @@ const init = () => { }, { type: 'separator' }, { + // this should be disabled when + // no windows are active label: 'Close Window', accelerator: 'CmdOrCtrl+Shift+W', - click: () => process.emit('close-window') + click: function (item, focusedWindow) { + if (focusedWindow) { + process.emit('close-window') + } + } }, { + // this should be disabled when + // no windows are active label: 'Close Tab', accelerator: 'CmdOrCtrl+W', click: function (item, focusedWindow) { - focusedWindow.webContents.send('shortcut-close-frame') + if (focusedWindow) { + focusedWindow.webContents.send('shortcut-close-frame') + } } } ]