Mercurial > sdl-ios-xcode
comparison src/video/quartz/SDL_QuartzVideo.m @ 4090:fedb379bedd0 SDL-1.2
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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 24 Jul 2007 04:21:05 +0000 |
parents | b8f2db95145e |
children | 9d90d7765fa7 |
comparison
equal
deleted
inserted
replaced
4089:37345dc3dd83 | 4090:fedb379bedd0 |
---|---|
367 SDL_free (sw_buffers[0]); | 367 SDL_free (sw_buffers[0]); |
368 } | 368 } |
369 | 369 |
370 /* If we still have a valid window, close it. */ | 370 /* If we still have a valid window, close it. */ |
371 if ( qz_window ) { | 371 if ( qz_window ) { |
372 [ qz_window close ]; | 372 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 */ |
373 [ qz_window release ]; | 373 [ qz_window close ]; /* includes release because [qz_window isReleasedWhenClosed] */ |
374 qz_window = nil; | 374 qz_window = nil; |
375 window_view = nil; | 375 window_view = nil; |
376 } | 376 } |
377 /* | 377 /* |
378 Release the OpenGL context | 378 Release the OpenGL context |
396 [ [ NSScreen mainScreen ] setFrame:screen_rect ]; | 396 [ [ NSScreen mainScreen ] setFrame:screen_rect ]; |
397 } | 397 } |
398 } | 398 } |
399 /* Release window mode resources */ | 399 /* Release window mode resources */ |
400 else { | 400 else { |
401 | 401 id delegate = [ qz_window delegate ]; |
402 [ qz_window close ]; | 402 [ qz_window close ]; /* includes release because [qz_window isReleasedWhenClosed] */ |
403 [ qz_window release ]; | 403 if (delegate != nil) [ delegate release ]; |
404 qz_window = nil; | 404 qz_window = nil; |
405 window_view = nil; | 405 window_view = nil; |
406 | 406 |
407 /* Release the OpenGL context */ | 407 /* Release the OpenGL context */ |
408 if ( mode_flags & SDL_OPENGL ) | 408 if ( mode_flags & SDL_OPENGL ) |
745 CGReleaseDisplayFadeReservation (fade_token); | 745 CGReleaseDisplayFadeReservation (fade_token); |
746 } | 746 } |
747 return NULL; | 747 return NULL; |
748 } | 748 } |
749 | 749 |
750 /*[ qz_window setReleasedWhenClosed:YES ];*/ | 750 /*[ qz_window setReleasedWhenClosed:YES ];*/ /* no need to set this as it's the default for NSWindows */ |
751 QZ_SetCaption(this, this->wm_title, this->wm_icon); | 751 QZ_SetCaption(this, this->wm_title, this->wm_icon); |
752 [ qz_window setAcceptsMouseMovedEvents:YES ]; | 752 [ qz_window setAcceptsMouseMovedEvents:YES ]; |
753 [ qz_window setViewsNeedDisplay:NO ]; | 753 [ qz_window setViewsNeedDisplay:NO ]; |
754 if ( center_window ) { | 754 if ( center_window ) { |
755 [ qz_window center ]; | 755 [ qz_window center ]; |
756 } | 756 } |
757 [ qz_window setDelegate: | 757 [ qz_window setDelegate: |
758 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ]; | 758 [ [ SDL_QuartzWindowDelegate alloc ] init ] ]; |
759 [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ]; | 759 [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ]; |
760 } | 760 } |
761 /* We already have a window, just change its size */ | 761 /* We already have a window, just change its size */ |
762 else { | 762 else { |
763 | 763 |