Make sure NSApp's references to the key and main window are cleared if the key/main window is deallocated.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18212 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-11-26 13:58:32 +00:00
parent da4e243597
commit 1f9cb4a03f
4 changed files with 34 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2003-11-26 14:47 Alexander Malmberg <alexander@malmberg.org>
* Headers/AppKit/NSApplication.h: Add -_windowWillDealloc:.
* Source/NSApplication.m: Fix some prototypes.
(-_windowWillDealloc:): Implement.
* Source/NSWindow.m (-dealloc): Call -_windowWillDealloc: so NSApp
can clear any unretained references to the window.
2003-11-25 17:16 Alexander Malmberg <alexander@malmberg.org>
* Source/NSWindow.m (-orderWindow:relativeTo:): Start the window

View file

@ -345,6 +345,11 @@ APPKIT_EXPORT NSString *NSEventTrackingRunLoopMode;
@end
#ifndef NO_GNUSTEP
@interface NSApplication (GSGUIInternal)
- (void) _windowWillDealloc: (NSWindow *)window;
@end
/*
* A formal protocol that duplicates the informal protocol for delegates.
*/

View file

@ -141,7 +141,7 @@ _NSAppKitUncaughtExceptionHandler (NSException *exception)
static NSBundle *guiBundle = nil;
/* Get the bundle. */
NSBundle *GSGuiBundle ()
NSBundle *GSGuiBundle (void)
{
return guiBundle;
}
@ -234,7 +234,7 @@ initialize_gnustep_backend(void)
}
void
gsapp_user_bundles()
gsapp_user_bundles(void)
{
NSUserDefaults *defs=[NSUserDefaults standardUserDefaults];
NSArray *a=[defs arrayForKey: @"GSAppKitUserBundles"];
@ -500,7 +500,7 @@ static NSCell* tileCell = nil;
* Dummy functions to fool linker into linking files that contain
* only catagories - static libraries seem to have problems here.
*/
extern void GSStringDrawingDummyFunction();
extern void GSStringDrawingDummyFunction(void);
GSStringDrawingDummyFunction();
@ -2881,3 +2881,17 @@ image.
}
@end // NSApplication (Private)
@implementation NSApplication (GSGUIInternal)
- (void) _windowWillDealloc: (NSWindow *)window
{
if (window == _key_window)
_key_window = nil;
if (window == _main_window)
_main_window = nil;
}
@end

View file

@ -646,6 +646,10 @@ many times.
target: self
argument: nil];
[NSApp removeWindowsItem: self];
[NSApp _windowWillDealloc: self];
NSAssert([NSApp keyWindow] != self, @"window being deallocated is key");
NSAssert([NSApp mainWindow] != self, @"window being deallocated is main");
if (_autosaveName != nil)
{