# HG changeset patch # User Sam Lantinga # Date 1185250865 0 # Node ID fedb379bedd005bcc21c52ba3c7044f169a115c8 # Parent 37345dc3dd83883abb724057b5720eac73c60c9f Fixed bug #458 ------- Comment #7 From Christian Walther 2007-07-23 01:10:30 [reply] ------- Fix for some Cocoa memory management problems. OK, I think I've nailed the memory management problems with the attached patch. Too late for the release, but oh well. It shows that I haven't done much Cocoa lately... took me a while to figure out that NSWindows don't retain their delegate. diff -r 37345dc3dd83 -r fedb379bedd0 src/video/quartz/SDL_QuartzVideo.m --- a/src/video/quartz/SDL_QuartzVideo.m Mon Jul 23 18:36:58 2007 +0000 +++ b/src/video/quartz/SDL_QuartzVideo.m Tue Jul 24 04:21:05 2007 +0000 @@ -369,8 +369,8 @@ /* If we still have a valid window, close it. */ if ( qz_window ) { - [ qz_window close ]; - [ qz_window release ]; + NSCAssert([ qz_window delegate ] == nil, @"full screen window shouldn't have a delegate"); /* if that should ever change, we'd have to release it here */ + [ qz_window close ]; /* includes release because [qz_window isReleasedWhenClosed] */ qz_window = nil; window_view = nil; } @@ -398,9 +398,9 @@ } /* Release window mode resources */ else { - - [ qz_window close ]; - [ qz_window release ]; + id delegate = [ qz_window delegate ]; + [ qz_window close ]; /* includes release because [qz_window isReleasedWhenClosed] */ + if (delegate != nil) [ delegate release ]; qz_window = nil; window_view = nil; @@ -747,7 +747,7 @@ return NULL; } - /*[ qz_window setReleasedWhenClosed:YES ];*/ + /*[ qz_window setReleasedWhenClosed:YES ];*/ /* no need to set this as it's the default for NSWindows */ QZ_SetCaption(this, this->wm_title, this->wm_icon); [ qz_window setAcceptsMouseMovedEvents:YES ]; [ qz_window setViewsNeedDisplay:NO ]; @@ -755,7 +755,7 @@ [ qz_window center ]; } [ qz_window setDelegate: - [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ]; + [ [ SDL_QuartzWindowDelegate alloc ] init ] ]; [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ]; } /* We already have a window, just change its size */