I have a core data document based application with a problem.

Some of the managed objects save a reference to a graphic context. These managed objects create graphic resources that are subsequently cleaned up in 'didTurnIntoFault'.

This works fine except for the following condition: A document is opened which contains an existing managed object, the object is then removed from the managed object context, and the window is then closed without saving changes. This results in a crash, because by the time 'didTurnIntoFault' is called, the graphic context is no longer valid.

The sequence of events are as follows:

1. User removes the managed object from the existing document (using array controller), presses the close window button, changes are not saved.

2. Managed object is removed from the managed object context by the frameworks and is no longer reachable by any means that I am aware of.

3. Method 'windowWillClose' is called by the window closing machinery and the document window, graphic view, and graphic context are released.

4. Managed object 'didTurnIntoFault' is finally called but it is too late, the graphic context is no longer valid!

Does anyone have any idea how I can fix this?

How can I get 'didTurnIntoFault' to be called before the window closing machinery takes over?

--Richard Somers

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to