From: Cheng Zhao Date: Thu, 4 Jun 2015 07:14:43 +0000 (+0800) Subject: Allow settting menu to null X-Git-Tag: v0.27.3~9^2~4 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6d6e75795f140565bc6b8f9952c551f667bf4e74;p=electron.git Allow settting menu to null --- diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index a0c1576a..5042b78a 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 b4b0dec2..80e03309 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()