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); } }