Mercurial > dwindows
changeset 736:5b48519a7fb2
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 15 Mar 2011 19:48:20 +0000 |
parents | b75be4860279 |
children | 680c7f365d0d |
files | mac/dw.m |
diffstat | 1 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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; } /*