changeset 35075:c40203dd82b7

Fix menu on newer OSX versions (at least 10.6) without breaking 10.5.
author reimar
date Wed, 12 Sep 2012 20:26:09 +0000
parents 3fb18ad99003
children 77a90f0b02b1
files libvo/vo_corevideo.m
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_corevideo.m	Tue Sep 11 21:31:21 2012 +0000
+++ b/libvo/vo_corevideo.m	Wed Sep 12 20:26:09 2012 +0000
@@ -575,10 +575,20 @@
 */
 - (void)initMenu
 {
+	NSMenu *mainMenu = [[NSMenu alloc] init];
 	NSMenu *menu, *aspectMenu;
 	NSMenuItem *menuItem;
 
-	[NSApp setMainMenu:[[NSMenu alloc] init]];
+	menu = [[NSMenu alloc] init];
+	menuItem = [[NSMenuItem alloc] init];
+	[menuItem setSubmenu:menu];
+	[mainMenu addItem:menuItem];
+	// Note: setAppleMenu seems to be unnecessary from 10.6 on,
+	// but is needed for all earlier versions or the menu is
+	// messed up.
+	// Round-about way with performSelector used to avoid compiler
+	// warnings.
+	[NSApp performSelector:@selector(setAppleMenu:) withObject:menu];
 
 //Create Movie Menu
 	menu = [[NSMenu alloc] initWithTitle:@"Movie"];
@@ -614,7 +624,7 @@
 	//Add to menubar
 	menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""];
 	[menuItem setSubmenu:menu];
-	[[NSApp mainMenu] addItem:menuItem];
+	[mainMenu addItem:menuItem];
 
 //Create Window Menu
 	menu = [[NSMenu alloc] initWithTitle:@"Window"];
@@ -625,8 +635,9 @@
 	//Add to menubar
 	menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
 	[menuItem setSubmenu:menu];
-	[[NSApp mainMenu] addItem:menuItem];
+	[mainMenu addItem:menuItem];
 	[NSApp setWindowsMenu:menu];
+	[NSApp setMainMenu:mainMenu];
 
 	[menu release];
 	[menuItem release];