Replacing 'NSApp' with the value returned from [NSApplication sharedApplication] is the last step to avoid null addresses in the x86 code. Go figure...

git-svn-id: https://svn.eduke32.com/eduke32@1906 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-06-17 11:58:37 +00:00
parent 043c756676
commit e1378c3020
1 changed files with 13 additions and 11 deletions

View File

@ -21,7 +21,7 @@
#define SDL_USE_NIB_FILE 0 #define SDL_USE_NIB_FILE 0
/* Use this flag to determine whether we use CPS (docking) or not */ /* Use this flag to determine whether we use CPS (docking) or not */
#define SDL_USE_CPS 1 #define SDL_USE_CPS
#ifdef SDL_USE_CPS #ifdef SDL_USE_CPS
/* Portions of CPS.h */ /* Portions of CPS.h */
typedef struct CPSProcessSerNum typedef struct CPSProcessSerNum
@ -41,6 +41,8 @@ static char **gArgv;
static BOOL gFinderLaunch; static BOOL gFinderLaunch;
static BOOL gCalledAppMainline = FALSE; static BOOL gCalledAppMainline = FALSE;
static id nsapp;
static NSString *getApplicationName(void) static NSString *getApplicationName(void)
{ {
const NSDictionary *dict; const NSDictionary *dict;
@ -157,10 +159,10 @@ static void setApplicationMenu(void)
/* Put menu into the menubar */ /* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu]; [menuItem setSubmenu:appleMenu];
[[NSApp mainMenu] addItem:menuItem]; [[nsapp mainMenu] addItem:menuItem];
/* Tell the application object that this is now the application menu */ /* Tell the application object that this is now the application menu */
[NSApp setAppleMenu:appleMenu]; [nsapp setAppleMenu:appleMenu];
/* Finally give up our references to the objects */ /* Finally give up our references to the objects */
[appleMenu release]; [appleMenu release];
@ -184,10 +186,10 @@ static void setupWindowMenu(void)
/* Put menu into the menubar */ /* Put menu into the menubar */
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
[windowMenuItem setSubmenu:windowMenu]; [windowMenuItem setSubmenu:windowMenu];
[[NSApp mainMenu] addItem:windowMenuItem]; [[nsapp mainMenu] addItem:windowMenuItem];
/* Tell the application object that this is now the window menu */ /* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu]; [nsapp setWindowsMenu:windowMenu];
/* Finally give up our references to the objects */ /* Finally give up our references to the objects */
[windowMenu release]; [windowMenu release];
@ -201,7 +203,7 @@ static void CustomApplicationMain (int argc, char **argv)
SDLMain *sdlMain; SDLMain *sdlMain;
/* Ensure the application object is initialised */ /* Ensure the application object is initialised */
[NSApplication sharedApplication]; nsapp = [NSApplication sharedApplication];
#ifdef SDL_USE_CPS #ifdef SDL_USE_CPS
{ {
@ -215,16 +217,16 @@ static void CustomApplicationMain (int argc, char **argv)
#endif /* SDL_USE_CPS */ #endif /* SDL_USE_CPS */
/* Set up the menubar */ /* Set up the menubar */
[NSApp setMainMenu:[[NSMenu alloc] init]]; [nsapp setMainMenu:[[NSMenu alloc] init]];
setApplicationMenu(); setApplicationMenu();
setupWindowMenu(); setupWindowMenu();
/* Create SDLMain and make it the app delegate */ /* Create SDLMain and make it the app delegate */
sdlMain = [[SDLMain alloc] init]; sdlMain = [[SDLMain alloc] init];
[NSApp setDelegate:sdlMain]; [nsapp setDelegate:sdlMain];
/* Start the main event loop */ /* Start the main event loop */
[NSApp run]; [nsapp run];
[sdlMain release]; [sdlMain release];
[pool release]; [pool release];
@ -292,7 +294,7 @@ static void CustomApplicationMain (int argc, char **argv)
#if SDL_USE_NIB_FILE #if SDL_USE_NIB_FILE
/* Set the main menu to contain the real app name instead of "SDL App" */ /* Set the main menu to contain the real app name instead of "SDL App" */
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; [self fixMenu:[nsapp mainMenu] withAppName:getApplicationName()];
#endif #endif
/* Hand off to main application code */ /* Hand off to main application code */