Author: paullanders
Date: Mon Aug 17 19:35:12 2015
New Revision: 38902

URL: http://svn.gna.org/viewcvs/gnustep?rev=38902&view=rev
Log:
Fixes undoing in the field editor. Adds separate undoManager class to prevent 
the field editor from corrupting the window's undo manager. 

Modified:
    
libs/base/branches/gnustep_testplant_branch/Headers/Foundation/NSUndoManager.h
    libs/base/branches/gnustep_testplant_branch/Source/NSUndoManager.m

Modified: 
libs/base/branches/gnustep_testplant_branch/Headers/Foundation/NSUndoManager.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Headers/Foundation/NSUndoManager.h?rev=38902&r1=38901&r2=38902&view=diff
==============================================================================
--- 
libs/base/branches/gnustep_testplant_branch/Headers/Foundation/NSUndoManager.h  
    (original)
+++ 
libs/base/branches/gnustep_testplant_branch/Headers/Foundation/NSUndoManager.h  
    Mon Aug 17 19:35:12 2015
@@ -145,6 +145,18 @@
 
 @end
 
+@interface NSCellUndoManager : NSUndoManager
+// Special undo manager for the field editor so that it doesn't interfere with 
the window's undo manager.
+{
+  NSUndoManager * _nextUndoManager;
+}
+- (BOOL)canUndo;
+- (void)undo;
+- (BOOL)canRedo;
+- (void)redo;
+- (void)setNextUndoManager:(NSUndoManager *)manager;
+@end
+
 #if    defined(__cplusplus)
 }
 #endif

Modified: libs/base/branches/gnustep_testplant_branch/Source/NSUndoManager.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/NSUndoManager.m?rev=38902&r1=38901&r2=38902&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/NSUndoManager.m  
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/NSUndoManager.m  Mon Aug 
17 19:35:12 2015
@@ -1026,13 +1026,14 @@
       return;
     }
 
+  _isUndoing = YES;
+
   [[NSNotificationCenter defaultCenter]
       postNotificationName: NSUndoManagerWillUndoChangeNotification
                    object: self];
 
   oldGroup = _group;
   _group = nil;
-  _isUndoing = YES;
 
   if (oldGroup)
     {
@@ -1102,3 +1103,57 @@
   return NO;
 }
 @end
+
+
+@implementation NSCellUndoManager
+
+- (void)dealloc
+{
+  [_nextUndoManager release];
+  [super dealloc];
+}
+
+- (BOOL)canUndo
+{
+  return [super canUndo] || [_nextUndoManager canUndo];
+}
+
+- (void)undo
+{
+  if ([super canUndo])
+    {
+      [super undo];
+    }
+  else
+    {
+      [_nextUndoManager undo];
+    }
+}
+
+- (BOOL)canRedo
+{
+  return [_nextUndoManager canRedo] || [super canRedo];
+}
+
+- (void)redo
+{
+  if ([_nextUndoManager canRedo])
+    {
+      [_nextUndoManager redo];
+    }
+  else
+    {
+      [super redo];
+    }
+}
+
+- (void)setNextUndoManager:(NSUndoManager *)manager
+{
+  [manager retain];
+  [_nextUndoManager release];
+  _nextUndoManager = manager;
+}
+
+@end
+
+


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to