Window close/dealloc fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6115 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-02-25 17:43:32 +00:00
parent 79446c8245
commit 2189aa34d7
4 changed files with 38 additions and 11 deletions

View file

@ -1,3 +1,10 @@
Fri Feb 25 16:20:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Headers/AppKit/NSWindow.h: added has_closed flag
* Source/NSWindow.m: made close/deallocation sequence more robust
* Source/NSApplication.m: improve removal of windows from menus
on close.
2000-02-25 Adam Fedor <fedor@gnu.org>
* Source/NSCursor.m ([NSCursor -setImage:]): Implement.

View file

@ -143,6 +143,7 @@ extern NSSize NSTokenSize;
unsigned hides_on_deactivate:1;
unsigned accepts_mouse_moved:1;
unsigned has_opened:1;
unsigned has_closed:1;
} _f;
/* Reserved for back-end use */

View file

@ -1833,22 +1833,25 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
{
NSArray *itemArray;
unsigned count;
unsigned i;
BOOL found = NO;
itemArray = [menu itemArray];
count = [itemArray count];
for (i = 0; i < count; i++)
while (count-- > 0)
{
id item = [itemArray objectAtIndex: i];
id item = [itemArray objectAtIndex: count];
if ([item target] == aWindow)
{
[menu removeItem: item];
[menu sizeToFit];
[menu update];
break;
found = YES;
}
}
if (found == YES)
{
[menu sizeToFit];
[menu update];
}
}
}

View file

@ -218,6 +218,7 @@ static NSMapTable* windowmaps = NULL;
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
target: self
argument: nil];
[NSApp removeWindowsItem: self];
[self setFrameAutosaveName: nil];
TEST_RELEASE(_wv);
@ -776,6 +777,10 @@ static NSMapTable* windowmaps = NULL;
NSModalPanelRunLoopMode,
NSEventTrackingRunLoopMode, nil]];
}
if (_f.has_closed == YES)
{
_f.has_closed = NO; /* A closed window has re-opened */
}
if (_f.has_opened == NO)
{
_f.has_opened = YES;
@ -1323,14 +1328,24 @@ resetCursorRectsForView(NSView *theView)
[nc postNotificationName: NSWindowWillCloseNotification object: self];
_f.has_opened = NO;
[[NSRunLoop currentRunLoop]
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
target: self
argument: nil];
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
target: self
argument: nil];
[NSApp removeWindowsItem: self];
[self orderOut: self];
RELEASE(pool);
if (_f.is_released_when_closed)
RELEASE(self);
if (_f.has_closed == NO)
{
_f.has_closed = YES;
if (_f.is_released_when_closed)
{
RELEASE(self);
}
}
else
{
NSWarnMLog(@"closing window (%@) that's already closed.", self);
}
}
- (void) deminiaturize: sender
@ -2932,6 +2947,7 @@ resetCursorRectsForView(NSView *theView)
_f.hides_on_deactivate = NO;
_f.accepts_mouse_moved = NO;
_f.has_opened = NO;
_f.has_closed = NO;
}
- (id) cleanInit