Revision: 13516
          http://sourceforge.net/p/skim-app/code/13516
Author:   hofman
Date:     2023-06-28 15:58:57 +0000 (Wed, 28 Jun 2023)
Log Message:
-----------
only register undo for duration of transition for the first time in an undo 
group, moving the slider fires a lot of changes in the same group that should 
be undone together

Modified Paths:
--------------
    trunk/SKPresentationOptionsSheetController.h
    trunk/SKPresentationOptionsSheetController.m

Modified: trunk/SKPresentationOptionsSheetController.h
===================================================================
--- trunk/SKPresentationOptionsSheetController.h        2023-06-27 15:26:19 UTC 
(rev 13515)
+++ trunk/SKPresentationOptionsSheetController.h        2023-06-28 15:58:57 UTC 
(rev 13516)
@@ -57,6 +57,7 @@
     NSArray *transitions;
     SKMainWindowController *controller;
     NSUndoManager *undoManager;
+    NSMutableSet *changedTransitions;
 }
 
 @property (nonatomic, retain) IBOutlet NSPopUpButton *notesDocumentPopUpButton;

Modified: trunk/SKPresentationOptionsSheetController.m
===================================================================
--- trunk/SKPresentationOptionsSheetController.m        2023-06-27 15:26:19 UTC 
(rev 13515)
+++ trunk/SKPresentationOptionsSheetController.m        2023-06-28 15:58:57 UTC 
(rev 13516)
@@ -113,6 +113,7 @@
     );
     SKDESTROY(transition);
     SKDESTROY(transitions);
+    SKDESTROY(changedTransitions);
     SKDESTROY(undoManager);
     SKDESTROY(notesDocumentPopUpButton);
     SKDESTROY(tableView);
@@ -364,9 +365,15 @@
 
 #pragma mark Undo
 
+- (void)observeUndoManagerCheckpoint:(NSNotification *)notification {
+    SKDESTROY(changedTransitions);
+}
+
 - (NSUndoManager *)undoManager {
-    if (undoManager == nil)
+    if (undoManager == nil) {
         undoManager = [[NSUndoManager alloc] init];
+        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(observeUndoManagerCheckpoint:) 
name:NSUndoManagerCheckpointNotification object:undoManager];
+    }
     return undoManager;
 }
 
@@ -402,6 +409,14 @@
         if ([newValue isEqual:[NSNull null]]) newValue = nil;
         if ([oldValue isEqual:[NSNull null]]) oldValue = nil;
         
+        if ([keyPath isEqualToString:DURATION_KEY]) {
+            if ([changedTransitions containsObject:object])
+                return;
+            if (changedTransitions == nil)
+                changedTransitions = [[NSMutableSet alloc] init];
+            [changedTransitions addObject:object];
+        }
+        
         if ((newValue || oldValue) && [newValue isEqual:oldValue] == NO)
             [[[self undoManager] prepareWithInvocationTarget:self] 
setValue:oldValue forKey:keyPath ofTransition:object];
     } else {

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to