]> khamidou — GitHub mirrors - electron.git/commitdiff
cocoa: Enable creating empty menu
authorCheng Zhao <zcbenz@gmail.com>
Sun, 16 Nov 2014 13:06:16 +0000 (21:06 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 16 Nov 2014 13:06:16 +0000 (21:06 +0800)
atom/browser/ui/cocoa/atom_menu_controller.mm

index 5013f5a9ee8a3922d8e58aec566736f274d0ec35..69a7b56826d7b7253869be13fe493dd56565ec09 100644 (file)
@@ -251,10 +251,13 @@ int EventFlagsFromNSEvent(NSEvent* event) {
 }
 
 - (NSMenu*)menu {
-  if (!menu_ && model_) {
-    menu_.reset([[self menuFromModel:model_] retain]);
-    [menu_ setDelegate:self];
-  }
+  if (menu_)
+    return menu_.get();
+
+  menu_.reset([[NSMenu alloc] initWithTitle:@""]);
+  [menu_ setDelegate:self];
+  if (model_)
+    [self populateWithModel:model_];
   return menu_.get();
 }