Revision: 27484
          http://sourceforge.net/p/bibdesk/svn/27484
Author:   hofman
Date:     2022-05-26 15:06:27 +0000 (Thu, 26 May 2022)
Log Message:
-----------
reuse the same undo managert for all note text views, we remove all actions 
when switching tabs

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.h
    trunk/bibdesk/BDSKEditor.m

Modified: trunk/bibdesk/BDSKEditor.h
===================================================================
--- trunk/bibdesk/BDSKEditor.h  2022-05-26 14:12:17 UTC (rev 27483)
+++ trunk/bibdesk/BDSKEditor.h  2022-05-26 15:06:27 UTC (rev 27484)
@@ -66,10 +66,7 @@
     NSTextView *currentEditedView;
     NSString *previousValueForCurrentEditedView;
     
-    // each textview gets its own undo manager
-    NSUndoManager *notesViewUndoManager;
-    NSUndoManager *abstractViewUndoManager;
-    NSUndoManager *rssDescriptionViewUndoManager;
+    NSUndoManager *textViewUndoManager;
     
     // for the splitview double-click handling
        CGFloat lastFileViewWidth;

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2022-05-26 14:12:17 UTC (rev 27483)
+++ trunk/bibdesk/BDSKEditor.m  2022-05-26 15:06:27 UTC (rev 27484)
@@ -339,9 +339,7 @@
     BDSKDESTROY(addedFields);
     BDSKDESTROY(statusBar);
     BDSKDESTROY(previousValueForCurrentEditedView);
-    BDSKDESTROY(notesViewUndoManager);
-    BDSKDESTROY(abstractViewUndoManager);
-    BDSKDESTROY(rssDescriptionViewUndoManager);   
+    BDSKDESTROY(textViewUndoManager);
        BDSKDESTROY(dragFieldEditor);
     BDSKDESTROY(tableCellFormatter);
     BDSKDESTROY(crossrefFormatter);
@@ -2365,9 +2363,7 @@
 // crash if you edit in one view, switch tabs, switch back to the previous 
view and hit undo.
 // We can't use textDidEndEditing, since just switching tabs doesn't change 
first responder.
 - (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem 
*)tabViewItem{
-    [notesViewUndoManager removeAllActions];
-    [abstractViewUndoManager removeAllActions];
-    [rssDescriptionViewUndoManager removeAllActions];
+    [textViewUndoManager removeAllActions];
 }
 
 - (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem 
*)tabViewItem{
@@ -2480,23 +2476,26 @@
                 NSString *tmpValue = [[publication 
valueOfField:BDSKAnnoteString inherit:NO] copy];
                 [notesView setString:(tmpValue == nil ? @"" : tmpValue)];
                 [tmpValue release];
-                if(currentEditedView == notesView)
+                if(currentEditedView == notesView){
                     [[self window] makeFirstResponder:[self window]];
-                [notesViewUndoManager removeAllActions];
+                    [textViewUndoManager removeAllActions];
+                }
             } else if([changeKey isEqualToString:BDSKAbstractString]){
                 NSString *tmpValue = [[publication 
valueOfField:BDSKAbstractString inherit:NO] copy];
                 [abstractView setString:(tmpValue == nil ? @"" : tmpValue)];
                 [tmpValue release];
-                if(currentEditedView == abstractView)
+                if(currentEditedView == abstractView){
                     [[self window] makeFirstResponder:[self window]];
-                [abstractViewUndoManager removeAllActions];
+                    [textViewUndoManager removeAllActions];
+                }
             } else if([changeKey isEqualToString:BDSKRssDescriptionString]){
                 NSString *tmpValue = [[publication 
valueOfField:BDSKRssDescriptionString inherit:NO] copy];
                 [rssDescriptionView setString:(tmpValue == nil ? @"" : 
tmpValue)];
                 [tmpValue release];
-                if(currentEditedView == rssDescriptionView)
+                if(currentEditedView == rssDescriptionView){
                     [[self window] makeFirstResponder:[self window]];
-                [rssDescriptionViewUndoManager removeAllActions];
+                    [textViewUndoManager removeAllActions];
+                }
             }
         }
     }
@@ -2531,9 +2530,7 @@
             [tmpValue release];
             if(currentEditedView)
                 [[self window] makeFirstResponder:[self window]];
-            [notesViewUndoManager removeAllActions];
-            [abstractViewUndoManager removeAllActions];
-            [rssDescriptionViewUndoManager removeAllActions];
+            [textViewUndoManager removeAllActions];
         }
     }
     else if([changeKey isEqualToString:BDSKColorString] == NO){
@@ -3058,19 +3055,9 @@
 
 // ... except for the abstract/annote/rss text views.
 - (NSUndoManager *)undoManagerForTextView:(NSTextView *)aTextView {
-       if(aTextView == notesView){
-        if(notesViewUndoManager == nil)
-            notesViewUndoManager = [[BDSKTextUndoManager alloc] 
initWithNextUndoManager:[self undoManager]];
-        return notesViewUndoManager;
-    }else if(aTextView == abstractView){
-        if(abstractViewUndoManager == nil)
-            abstractViewUndoManager = [[BDSKTextUndoManager alloc] 
initWithNextUndoManager:[self undoManager]];
-        return abstractViewUndoManager;
-    }else if(aTextView == rssDescriptionView){
-        if(rssDescriptionViewUndoManager == nil)
-            rssDescriptionViewUndoManager = [[BDSKTextUndoManager alloc] 
initWithNextUndoManager:[self undoManager]];
-        return rssDescriptionViewUndoManager;
-       }else return [self undoManager];
+    if(textViewUndoManager == nil)
+        textViewUndoManager = [[BDSKTextUndoManager alloc] 
initWithNextUndoManager:[self undoManager]];
+    return textViewUndoManager;
 }
 
 #pragma mark TableView datasource methods

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to