Undo Causes Document Window to be Retained
Undo Causes Document Window to be Retained
- Subject: Undo Causes Document Window to be Retained
- From: Scott Johnson <email@hidden>
- Date: Wed, 10 Oct 2001 11:00:57 -0400
I have a document-based Cocoa application I've been working on that is
written in Objective-C. I am seeing instances where the following line
of code causes the document window to be retained.
[[[self undoManager] prepareWithInvocationTarget:self]
<someMethod>:<itsParameter>];
In this case, _self_ is the NSDocument-derived object. For reasons I
don't quite understand the window for this document object is retained
when updateChangeCount is called (as a result of the above call). The
problem is, it does not ever seem to be released; when the window is
closed by the user the application crashes because the OS is trying to
later redisplay the contents of a window which isn't there (but was
never fully released). I have no explicit code to retain or release the
window object. I have added code to removeAllActions from the
undoManager hoping that this would cause it to release the window to no
avail.
My questions are thus:
1. What would cause updateChangeCount to retain the window?
2. Why isn't the window released when the document is closed (assuming
the retain was for a valid purpose)?
Thanks for any insight you may have on this.
-Scott