I am currently experiencing some crashing due to an NSWindow's _performClose method being called after the document (which was its delegate) is freed. It looks like there is something wrong in the NSDocument infrastructure, because the _window ivar is never retained by NSDocument, but it is released on -dealloc (possibly this should be a -performClose or similar, because NSWindow is meant to retain itself and release itself when it is closed?).

This usually doesn't make much difference, because the window controller takes ownership, and then sets the _window ivar in the document to nil, and so the release message is sent to nil instead of the window.

The problem comes if you follow the common pattern of setting the document (the file's owner) as the window's delegate in the nib. In order for this not to crash when the window sends a respondsToSelector: message to the delegate while closing, the document must remove itself as the delegate before it exists. This would be easy, except that the window controller has stolen the window and the window controller itself has removed itself from the array of window controllers by the time -dealloc is called, so there is no way for an NSDocument subclass to get the window in -dealloc and do this removal...

David

-- Sent from my Apple II



_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to