Re: NSUndoManager issues
Re: NSUndoManager issues
- Subject: Re: NSUndoManager issues
- From: Graham Cox <email@hidden>
- Date: Wed, 16 Dec 2009 11:15:49 +1100
On 15/12/2009, at 1:02 PM, Scott Squires wrote:
> I have some image processing routines that are on another thread and undo objects are created.
>
> When these are done in a series by the user (several minutes apart) and an undo is preformed then one by one they are invoked from just one undo request. The inverse is true for redo. The non-threaded items work as expected. if a non-threaded item is done after a threaded item then it all works correctly.
>
> Is there a reason for this and how do I make sure each undo action from the user only causes one undo step to be preformed?
>
I haven't experimented with Undo from another thread, but I suspect that's going to be awkward, if it's even allowed.
On the main thread, an undo group is automatically opened by the first task submitted to the undo manager and closed at the end of the event cycle, unless -setGroupsByEvent: is NO. Undo tasks submitted from a thread will be completely out of synch with this mechanism, so you'll find groups not being correctly formed - the opened group will be closed on the main thread regardless, I think, so they'll be closed at arbitrary points relative to the execution of the thread.
You should probably arrange for the thread to submit its undo tasks to the undo manager on the main thread, and give some thought to managing the groups manually.
At that point you'll probably start to run into the numerous bugs and glitches that NSUndoManager suffers from, and start to tear out your hair. That's been mine and others' experiences anyway.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden