Re: NSApplication Bug. Quit doesn't notify windows (& delegates), just kills them.
Re: NSApplication Bug. Quit doesn't notify windows (& delegates), just kills them.
- Subject: Re: NSApplication Bug. Quit doesn't notify windows (& delegates), just kills them.
- From: "R. Tony Goold" <email@hidden>
- Date: Tue, 17 Jul 2001 22:51:52 -0400
Here's the Bug:
1) in my window delegate:
windowShouldClose IS called if I hit the close dot (red dot) in the
window title bar.
windowShouldClose IS called if I select the "Close" command in the
File menu.
Here's the BUG/Design flaw:
windowShouldClose IS NOT CALLED if I select "Quit" from the
application menu.
I'm not sure why you see this as a bug. When an application quits, the
only things the operating system should close for it are external
resources such as files and sockets, or buffers owned by the operating
system. It doesn't need to close windows because those windows are going
to be completely destroyed anyway.
There was a similar post earlier (possibly by you? I can't find it)
regarding objects not having their dealloc method called when the
application quits. To call the dealloc method for every object would
require the application or operating system to track every single one of
them and iterate through the list, being smart enough not to release
objects that are already released by other objects as part of their
deallocation. The OS takes the simpler route of just reclaiming that space
without concerning itself about what lies within.
If you need to do any clean-up with your application quits, you should
catch a quit notification and respond accordingly, closing whatever
windows need to be closed (before being destroyed) and releasing whatever
objects need to be released.
Hope this helps... I'm still learning quite a bit of Cocoa myself :-)
Cheers,
Tony