From 6d6e75795f140565bc6b8f9952c551f667bf4e74 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 4 Jun 2015 15:14:43 +0800 Subject: [PATCH] Allow settting menu to null --- atom/browser/api/lib/browser-window.coffee | 2 +- atom/browser/api/lib/menu.coffee | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index a0c1576ad533..5042b78a3adc 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -73,7 +73,7 @@ BrowserWindow::setMenu = (menu) -> if process.platform is 'darwin' throw new Error('BrowserWindow.setMenu is not available on OS X') - throw new TypeError('Invalid menu') unless menu?.constructor?.name is 'Menu' + throw new TypeError('Invalid menu') unless menu is null or menu?.constructor?.name is 'Menu' @menu = menu # Keep a reference of menu in case of GC. @menu.attachToWindow this diff --git a/atom/browser/api/lib/menu.coffee b/atom/browser/api/lib/menu.coffee index b4b0dec23e20..80e0330943e7 100644 --- a/atom/browser/api/lib/menu.coffee +++ b/atom/browser/api/lib/menu.coffee @@ -130,11 +130,12 @@ Menu::_callMenuWillShow = -> applicationMenu = null Menu.setApplicationMenu = (menu) -> - throw new TypeError('Invalid menu') unless menu?.constructor is Menu + throw new TypeError('Invalid menu') unless menu is null or menu.constructor is Menu applicationMenu = menu # Keep a reference. if process.platform is 'darwin' menu._callMenuWillShow() + throw new Error('You can not remove application menu') if menu is null bindings.setApplicationMenu menu else windows = BrowserWindow.getAllWindows()