# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1300218500 0 # Node ID 5b48519a7fb2b13ed6828949eecd5433d18d506d # Parent b75be48602792c119808352cfa3c710a15f62557 Added retains to the window menus so they don't get autoreleased when switching between windows with menus. Added release to the dealloc method so they won't stick around forever. diff -r b75be4860279 -r 5b48519a7fb2 mac/dw.m --- a/mac/dw.m Tue Mar 15 19:20:30 2011 +0000 +++ b/mac/dw.m Tue Mar 15 19:48:20 2011 +0000 @@ -542,8 +542,12 @@ } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [super dealloc]; + if(windowmenu) + { + [windowmenu release]; + } + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; } - (void)windowResized:(NSNotification *)notification; { @@ -563,7 +567,7 @@ } _event_handler(self, nil, 13); } --(void)setMenu:(NSMenu *)input { windowmenu = input; } +-(void)setMenu:(NSMenu *)input { windowmenu = input; [windowmenu retain]; } -(void)menuHandler:(id)sender { _event_handler(sender, nil, 8); } -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); } @end @@ -7453,29 +7457,30 @@ */ int API dw_init(int newthread, int argc, char *argv[]) { - /* Create the application object */ - DWApp = [NSApplication sharedApplication]; - /* Create object for handling timers */ - DWHandler = [[DWTimerHandler alloc] init]; + /* Create the application object */ + DWApp = [NSApplication sharedApplication]; + /* Create object for handling timers */ + DWHandler = [[DWTimerHandler alloc] init]; /* If we aren't using garbage collection we need autorelease pools */ #if !defined(GARBAGE_COLLECT) pthread_key_create(&_dw_pool_key, NULL); - pool = [[NSAutoreleasePool alloc] init]; + pool = [[NSAutoreleasePool alloc] init]; pthread_setspecific(_dw_pool_key, pool); #endif /* Create a default main menu, with just the application menu */ - DWMainMenu = _generate_main_menu(); - [DWApp setMainMenu:DWMainMenu]; - DWObj = [[DWObject alloc] init]; + DWMainMenu = _generate_main_menu(); + [DWMainMenu retain]; + [DWApp setMainMenu:DWMainMenu]; + DWObj = [[DWObject alloc] init]; /* Create mutexes for thread safety */ DWRunMutex = dw_mutex_new(); DWThreadMutex = dw_mutex_new(); DWThreadMutex2 = dw_mutex_new(); /* Use NSThread to start a dummy thread to initialize the threading subsystem */ - NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil]; - [thread start]; + NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil]; + [thread start]; [thread release]; - return 0; + return 0; } /*