On 17/12/2009, at 7:13 AM, Scott Squires wrote:

> Is there a clean method (which I take it is the group method) to make sure 
> that undo functions aren't automatically grouped based on event cycles?  Is 
> there a recommended way of dealing with UI and async actions relative to the 
> undomanager?


To turn off automatic grouping, call -setGroupsByEvent:NO. You'll then be 
responsible for opening and closing the top-level group yourself. You must do 
this - having no group open is an error.

You must submit all your tasks to the undo manager on the main thread.

Even so, I imagine you'll run into problems, because your thread is not running 
in any way synchronised to the main event loop - therefore you may end up with 
some tasks in one group and others in another depending on what is happening on 
the main thread with undo coming from elsewhere. Personally I'm not sure that 
can be reconciled. It might be better if your thread can prepare some object 
which sets an undoable property on the main thread in one go when it's done, 
rather than attempt to submit individual tasks to the undo manager. I just 
don't think it's designed to handle that situation (in fact I know it's not) 
and you'll end up doing a crazy amount of work to make it operate sanely.

> You imply that there are undomanager issues.  Are there known ones I and 
> others should be aware of?

The main problem is that it's not a solution for every possible Undo need, so 
where your requirements are slightly off the norm, it's often a lot of work to 
bend it to your will. It's also a black box with a large private API and 
internal structure unpublished, undocumented and difficult to override or 
figure out what's happening when it's not co-operating. For the most 
straightforward, single main-event-loop based Undo, it's great. 80:20 rule 
applies - if you're in the 20% though, it can be painful.

I outlined some of the rationale I had for writing my own Undo class on my 
website: http://apptree.net/gcundomanager.htm

--Graham_______________________________________________

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