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: Mon, 7 Dec 2009 10:12:46 +1100
It's not just me running into undo problems - ironically just got this from Xcode (requiring quit and relaunch to recover) while trying to build after tweaking my undo manager source:
"Internal error occurred while creating dependency graph: _registerUndoObject:: NSUndoManager 0x3befcb10 is in invalid state, must begin a group before registering undo".
(Why it needs to register with Undo while building the dependency graph is another question - it's not as if you can undo that or would want to).
On 07/12/2009, at 7:00 AM, Quincey Morris wrote:
>> I tried it but it doesn't work. I forget the details now as this was my first approach and that was a long time ago, but basically the undo manager didn't tolerate having groups deferred until a task was actually received. It would crash, but without the code, I couldn't say why .
>
> I'm not sure I understand this point. Are you talking about a situation with 'setGroupsByEvent:YES' or 'setGroupsByEvent:NO'? Either way, an explicit call to 'beginUndoGrouping:' is *by definition* deferred, since it obviously can't happen the instant an event is dequeued. The length of time between dequeuing an event and invoking an undo manager method seems irrelevant. But I ask mainly out of curiosity because ...
I think my understanding of how groups by event works was shaky at the time, so it's possible that I did something silly. Quite likely in fact. The deferrment was in a subclass of course, and it was in the situation where groupsByEvent was NO, and I wanted to group a bunch of drags. I set a flag on -beginUndoGrouping but did not call super. Then when a task was received from a drag change, if the flag was set I called super's -beginUndoGrouping "just in time". That's when it crashed if I recall correctly.
>> An undo manager collects all undo operations that occur within a single cycle of the run loop, so that performing an undo reverts all changes that occurred during the cycle.
>
> Taken literally, that would seem to say that NSUndoManager's API contract doesn't support undo actions that span events. FWIW.
Yes, which does make me wonder how others have implemented undo of drags in general. Is there a simple solution staring me in the face and I just can't see it?
I think I'm in a drag-induced stupor, but if I can get this to work elegantly perhaps I could be a drag artist ;-)
--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