Behavior of autoreleased window controller for closing window vs. app termination
Behavior of autoreleased window controller for closing window vs. app termination
- Subject: Behavior of autoreleased window controller for closing window vs. app termination
- From: Alan Nilsson <email@hidden>
- Date: Mon, 30 Sep 2002 17:18:26 -0700
I have a window controller sub class that I am using to create multiple
windows from. I create instances of the window controller then autorelease
them in the windowWillClose delegate method.
Everything is hunky dory as long as I close the window with CMMD-W or by
clicking on the close button, but if I quit the app (issue a NSApp
terminate) with one of these windows open, I crash.
What is really confusing me is that when I close the window,
'windowWillClose' gets called once, but if I terminate the app with a window
open, 'windowWillClose' gets called twice.
This is how I am creating the window's:
-(void)openUser:(int)theUserID
{
UserController* usrWindow;
usrWindow = [[UserController alloc] initWithPersonID:theUserID];
[usrWindow setWindowFrameAutosaveName:@"User"];
[usrWindow showWindow:self];
}
Init code is:
- (id)initWithPersonID:(int)ID
{
self = [super initWithWindowNibName:@"User2"];
NSLog(@"Creating User Controller for %d",ID);
return self;
}
Finally windowWillClose code is:
-(void) windowWillClose:(NSNotification *)aNotification
{
[self autorelease];
NSLog(@"count = %d for %d",[self retainCount],[currentEmp personID]);
}
Results:
2002-09-30 17:14:19.516 STE User Tool[1664] Creating User Controller for
295207
2002-09-30 17:14:23.040 STE User Tool[1664] retain count = 1 for 295207
2002-09-30 17:14:23.040 STE User Tool[1664] retain count = 1 for 295207
2002-09-30 17:14:23.072 STE User Tool[1664] Deallocating
STE User Tool has exited due to signal 11 (SIGSEGV).
Can anyone give me any ideas of what is going wrong? Why I am seeing 2
calls to windowWillClose which obviously is over-releasing the window.
Alan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.