[Mac] Avoid calling finishLaunching multiple times
authorthefiddler <stapostol@gmail.com>
Thu, 11 Sep 2014 10:21:05 +0000 (12:21 +0200)
committerthefiddler <stapostol@gmail.com>
Thu, 11 Sep 2014 10:21:05 +0000 (12:21 +0200)
Source/OpenTK/Platform/MacOS/Cocoa/NSApplication.cs

index 475262b..82bde26 100644 (file)
@@ -79,10 +79,13 @@ namespace OpenTK.Platform.MacOS
 
                 Cocoa.SendIntPtr(appMenu, Selector.Get("addItem:"), quitMenuItem);
                 Cocoa.SendIntPtr(menuItem, Selector.Get("setSubmenu:"), appMenu);
-            }
 
-            // Tell cocoa we're ready to run the application (usually called by [NSApp run]). 
-            Cocoa.SendVoid(Handle, Selector.Get("finishLaunching"));
+                // Tell cocoa we're ready to run the application (usually called by [NSApp run]). 
+                // Note: if a main menu exists, then this method has already been called and
+                // calling it again will result in a crash. For this reason, we only call it
+                // when we create our own main menu.
+                Cocoa.SendVoid(Handle, Selector.Get("finishLaunching"));
+            }
 
             // Disable momentum scrolling and long-press key pop-ups
             IntPtr settings = Cocoa.SendIntPtr(Class.NSDictionary, Selector.Alloc);