diff --git a/ChangeLog b/ChangeLog index 7f3327d0a..a583ed280 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-06-02 Wolfgang Lux + + * Source/NSUndoManager.m (-undo, -redo): Call -_begin instead of + -beginUndoGrouping to avoid creation of a spurious top-level group + while performing undo or redo operations, which was causing the + recorded actions to be dropped silently. + + * Source/NSUndoManager.m (-beginUndoGrouping): Post + NSUndoManagerCheckpointNotification also during undo as on OS X. + + * Source/NSUndoManager.m (-endUndoGrouping): Post + NSUndoManagerWillCloseUndoGroupNotification before changing the + group so that clients see the same grouping level as on OS X. + 2009-05-29 Riccardo Mottola * Source/NSObject.m: Atomic increment and decrement functions for m68k diff --git a/Source/NSUndoManager.m b/Source/NSUndoManager.m index d328a54ba..2c9436a1e 100644 --- a/Source/NSUndoManager.m +++ b/Source/NSUndoManager.m @@ -162,9 +162,9 @@ @implementation NSUndoManager (Private) /* This method is used to begin undo grouping internally. - * It's necessary to have a different mechanism from the -beginUndoGroup - * because it seems that in MacOS-X 10.5 a call to -beginUndoGroup when - * at the top level will actually create two undo groups. + * It's necessary to have a different mechanism from the -beginUndoGrouping + * because it seems that in MacOS X a call to -beginUndoGrouping when at the + * top level will actually create two undo groups. */ - (void) _begin { @@ -222,14 +222,14 @@ * It first posts an NSUndoManagerCheckpointNotification * unless an undo is currently in progress.
* The order of these notifications is undefined, but the GNUstep - * implementation currently mimics the observed order in MacOS-X 10.5 + * implementation currently mimics the observed order in MacOS X 10.5 */ - (void) beginUndoGrouping { - /* It seems that MacOS-X 10.5 implicitly creates a top-level group - * if this method is called when groupsByEvent is set and there is - * no existing top level group. There is no checkpoint notification - * posted for the implicit group creation. + /* It seems that MacOS X implicitly creates a top-level group if this + * method is called when groupsByEvent is set and there is no existing + * top level group. There is no checkpoint notification posted for the + * implicit group creation. */ if (_group == nil && [self groupsByEvent]) { @@ -238,12 +238,9 @@ /* Post the checkpoint notification and THEN create the group. */ - if (_isUndoing == NO) - { - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUndoManagerCheckpointNotification - object: self]; - } + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUndoManagerCheckpointNotification + object: self]; [self _begin]; // Start a new group } @@ -353,14 +350,14 @@ [[NSNotificationCenter defaultCenter] postNotificationName: NSUndoManagerCheckpointNotification object: self]; - g = (PrivateUndoGroup*)_group; - p = RETAIN([g parent]); - _group = p; - [g orphan]; if (_isUndoing == NO && _isRedoing == NO) [[NSNotificationCenter defaultCenter] postNotificationName: NSUndoManagerWillCloseUndoGroupNotification object: self]; + g = (PrivateUndoGroup*)_group; + p = RETAIN([g parent]); + _group = p; + [g orphan]; if (p == nil) { if (_isUndoing) @@ -640,7 +637,7 @@ _group = nil; _isRedoing = YES; - [self beginUndoGrouping]; + [self _begin]; [groupToRedo perform]; RELEASE(groupToRedo); [self endUndoGrouping]; @@ -1053,7 +1050,7 @@ name = [NSString stringWithString: [groupToUndo actionName]]; - [self beginUndoGrouping]; + [self _begin]; [groupToUndo perform]; RELEASE(groupToUndo); [self endUndoGrouping];