In -close, retain and release self to make sure it isn't deallocated too early.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14464 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2002-09-16 17:08:18 +00:00
parent 1ea2a1d020
commit 98a06d10ca
2 changed files with 17 additions and 4 deletions

View file

@ -2100,6 +2100,17 @@ resetCursorRectsForView(NSView *theView)
{
if (_f.has_closed == NO)
{
/* The NSWindowCloseNotification might result in us being
deallocated. To make sure self stays valid as long as is
necessary, we retain ourselves here and balance it with a
release later (unless we're supposed to release ourselves when
we close).
*/
if (!_f.is_released_when_closed)
{
RETAIN(self);
}
CREATE_AUTORELEASE_POOL(pool);
[nc postNotificationName: NSWindowWillCloseNotification object: self];
@ -2114,10 +2125,7 @@ resetCursorRectsForView(NSView *theView)
RELEASE(pool);
_f.has_closed = YES;
if (_f.is_released_when_closed)
{
RELEASE(self);
}
RELEASE(self);
}
}