Window retain/release fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6046 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-02-21 15:33:30 +00:00
parent 174b8c2cf1
commit d144de1a07
2 changed files with 23 additions and 13 deletions

View file

@ -833,6 +833,7 @@ static NSCell* tileCell = nil;
NSDebugLog(@"NSApplication -run\n"); NSDebugLog(@"NSApplication -run\n");
pool = [arpClass new];
/* /*
* Set this flag here in case the application is actually terminated * Set this flag here in case the application is actually terminated
* inside -finishLaunching. * inside -finishLaunching.
@ -845,6 +846,7 @@ static NSCell* tileCell = nil;
[listener updateServicesMenu]; [listener updateServicesMenu];
[main_menu update]; [main_menu update];
RELEASE(pool);
while (app_should_quit == NO) while (app_should_quit == NO)
{ {
pool = [arpClass new]; pool = [arpClass new];

View file

@ -117,6 +117,19 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
@implementation NSWindow @implementation NSWindow
- (int) arc
{
return [self retainCount] - [NSAutoreleasePool autoreleaseCountForObject: self];
}
- (void) release
{
[super release];
}
- (id) retain
{
return [super retain];
}
typedef struct NSView_struct typedef struct NSView_struct
{ {
@defs(NSView) @defs(NSView)
@ -214,6 +227,10 @@ static NSMapTable* windowmaps = NULL;
NSGraphicsContext *context = GSCurrentContext(); NSGraphicsContext *context = GSCurrentContext();
[[NSNotificationCenter defaultCenter] removeObserver: self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
[[NSRunLoop currentRunLoop]
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
target: self
argument: nil];
[self setFrameAutosaveName: nil]; [self setFrameAutosaveName: nil];
TEST_RELEASE(_wv); TEST_RELEASE(_wv);
@ -1314,15 +1331,7 @@ resetCursorRectsForView(NSView *theView)
- (void) close - (void) close
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
CREATE_AUTORELEASE_POOL(arp);
/*
* If '_f.is_released_when_closed' then the window will be removed from the
* global list of windows (causing it to be released) - so we must
* bracket any work we do in a retain/release sequence in case that
* removal takes place when we post the notification.
*/
if (_f.is_released_when_closed)
RETAIN(self);
[nc postNotificationName: NSWindowWillCloseNotification object: self]; [nc postNotificationName: NSWindowWillCloseNotification object: self];
_f.has_opened = NO; _f.has_opened = NO;
@ -1333,6 +1342,7 @@ resetCursorRectsForView(NSView *theView)
[NSApp removeWindowsItem: self]; [NSApp removeWindowsItem: self];
[self orderOut: self]; [self orderOut: self];
RELEASE(arp);
if (_f.is_released_when_closed) if (_f.is_released_when_closed)
RELEASE(self); RELEASE(self);
} }
@ -1499,9 +1509,7 @@ resetCursorRectsForView(NSView *theView)
{ {
if ([aView isKindOfClass: viewClass]) if ([aView isKindOfClass: viewClass])
{ {
if (_initial_first_responder) ASSIGN(_initial_first_responder, aView);
[_initial_first_responder autorelease];
_initial_first_responder = [aView retain];
} }
} }
@ -2362,7 +2370,7 @@ resetCursorRectsForView(NSView *theView)
name = [name copy]; name = [name copy];
[autosaveNames addObject: name]; [autosaveNames addObject: name];
autosave_name = name; autosave_name = name;
[name release]; RELEASE(name);
} }
else if (nameToRemove != nil) else if (nameToRemove != nil)
{ {