I am getting funny results using grouping in NSUndoManager.
If I begin a group on mouse down, and end the group on mouse up, even if I do nothing in between, it seems to record an undo task, with the plain name "Undo" in the menu, dirtying the document. The "task" is null - it doesn't actually undo anything.
When I go to close a document with its undo manager in this state, it hangs indefinitely before putting up the save changes dialog. (I get nothing i the log or GDB to indicate why it's hanging, but the dialog doesn't appear).
Surely it's incorrect for NSUndoManager to treat an empty group as a real undo task?
Working around this is proving to be extremely troublesome - for example I've tried subclassing NSUndoManager and overriding beginUndoGrouping, and for grouping beyond level zero, I defer the group opening until a task is actually received. Likewise, endUndoGrouping doesn't close the group if it was never really opened. Problem is, I can't get this to work - the docs are unclear about whether these exact methods are called by the standard event/run loop grouping (they appear not to be), and frankly the workings of undo groups seem to be shrouded in mystery.
The other workaround is to try and predict which operations between mouse down and mouse up really will make an undo task, and try and open a group "just in time" to receive them. Naturally given the hundreds of possible tasks that the mouse can create, this is a really difficult approach in and of itself.
Can someone confirm that undo groups are broken in this way, or if they are not broken, explain what the hell the logic is here?
Better still, has anyone written an NSUndoManager subclass that fixes this?
------ S.O.S. _______________________________________________ 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 [EMAIL PROTECTED]