[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUndoManager and NSInvocation

From: Sašo Kiselkov
Subject: NSUndoManager and NSInvocation
Date: Tue, 13 Sep 2005 09:16:55 +0200
User-agent: Internet Messaging Program (IMP) 3.2.5

Hi. If anybody reads the help-gnustep mailing list or GNUstep's bug-tracker then
you'll know of an NSUndoManager and NSInvocation issue. To sum it up:

 - the current implementation of NSUndoManager has the following bug: the
invocations it stores when doing invocation-based undo don't -retainArguments -
which results in crashes when the user does undo, since the arguments might have
been long deallocated. (If you want to test it, try the DataBuilder application
from http://gscoredata.nongnu.org)

 - when trying to fix it by doing -[NSInvocation retainArguments] in
-[NSUndoManager fowardInvocation:] another problem results: since the
invocation retains it's arguments and _target_ this creates a retain loop, as
the usual target of undo operations is an NSDocument, the owner of the

Together with Quentin we've investigated the issue and checked behavior with
Cocoa. Apple circumvented this by creating a custom subclass named
_NSUndoInvocation which does retain it's arguments, but not it's target.

I've fixed this by creating a method in NSInvocation called
-retainArgumentsIncludingTarget: where the sender of the message can explicitly
define whether to retain the target or not, and made NSUndoManager use it. A
tarball with the three fixed files (NSInvocation.[hm] and NSUndoManager.m) is
available at http://openspace.adlerka.sk/NSUndoManagerFix.tar.gz .


reply via email to

[Prev in Thread] Current Thread [Next in Thread]