Fix a few issues with NSUndoManager, the most serious of which was

that NSUndoManager did no longer record redo actions properly since
the recent Mac OS X compatibililty changes to it.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28320 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2009-06-02 21:36:17 +00:00
parent f3723a5426
commit 390aad3427
2 changed files with 31 additions and 20 deletions

View file

@ -1,3 +1,17 @@
2009-06-02 Wolfgang Lux <wolfgang.lux@gmail.com>
* 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 <rmottola@users.sf.net>
* Source/NSObject.m: Atomic increment and decrement functions for m68k

View file

@ -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.<br />
* 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];