• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Behavior of autoreleased window controller for closing window vs. app termination
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Behavior of autoreleased window controller for closing window vs. app termination
      • From: James DiPalma <email@hidden>
  • Prev by Date: Re: [newbie] Handling a preferences window
  • Next by Date: Re: linking in private non-Framework libraries
  • Previous by thread: Wishing for NSActionImageCell
  • Next by thread: Re: Behavior of autoreleased window controller for closing window vs. app termination
  • Index(es):
    • Date
    • Thread