From 98a06d10ca82d6f0e2a67da3e7ba151d20cdf209 Mon Sep 17 00:00:00 2001 From: Alexander Malmberg Date: Mon, 16 Sep 2002 17:08:18 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 +++++ Source/NSWindow.m | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ed3b631d..2a3ac8297 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-09-16 19:05 Alexander Malmberg + + * Source/NSWindow.m (-close): Retain and release self to make sure + it isn't deallocated until we're done. + 2002-09-15 Fred Kiefer * Source/NSStringDrawing.m diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 14c31f8c7..fead5a31f 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -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); } }