Re: Best way to hook into the run loop?
Re: Best way to hook into the run loop?
- Subject: Re: Best way to hook into the run loop?
- From: Graham Cox <email@hidden>
- Date: Sat, 5 Dec 2009 02:29:46 +1100
On 05/12/2009, at 2:19 AM, Mike Abdullah wrote:
> NSUndoManager works something like this:
>
> 1. The first time an action is registered, an undo group begins.
>
> 2. The group is scheduled to be closed using -[NSRunLoop performSelector:target:argument:order:modes:]. See the constants section of NSUndoManager for a little more detail.
>
> As simple as that :)
OK, that would appear to be the most obvious way to implement it.
However, what about the bug where opening and closing a group but doing nothing in between creates a bogus empty undo task? This comes into play when grouping things that occur over a series of events, for example mouse drags. It would be nice if I could just open a group on mouse down, and close it on mouse up. Depending on what the mouse actually does, it might not submit any undoable tasks to the undo manager. So this bug means that case has to be detected and the undo stack cleaned up. Ultimately this is the problem I'm trying to workaround - you would not believe how complicated it can get.
A related issue to the above is that if the mouse operation throws an exception (it generally shouldn't, but it can happen), the same group close and clean up has to be done. Otherwise Undo simply stops working because of the group imbalance.
It's really troublesome because so much of what's going on inside NSUndoManager is opaque to the app, debugger and everything else. And what's going on is definitely weird - like calling -endUndoGrouping and having the level stuck at 1 before and after.
I've had so much grief with the UM that I'm basically prepared to write my own - in fact I have it 99% working now (passes all its unit tests) just need to see if it will work in a real situation.
--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