Revision: 15993
          http://sourceforge.net/p/skim-app/code/15993
Author:   hofman
Date:     2026-01-10 16:35:36 +0000 (Sat, 10 Jan 2026)
Log Message:
-----------
rewind using timer rather than GCD so we can cancel it

Modified Paths:
--------------
    trunk/SKPDFView.m

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2026-01-10 15:46:01 UTC (rev 15992)
+++ trunk/SKPDFView.m   2026-01-10 16:35:36 UTC (rev 15993)
@@ -557,7 +557,7 @@
 #pragma mark Accessors
 
 - (void)setDocument:(PDFDocument *)document {
-    rewindPage = nil;
+    [self setNeedsRewind:nil];
     
     BOOL shouldHideReadingBar = [syncDot shouldHideReadingBar];
     [syncDot invalidate];
@@ -1531,24 +1531,28 @@
     }
 }
 
+- (void)doInitialRewind {
+    if (rewindPage && [self pageForPoint:SKCenterPoint([self 
unobscuredContentRect]) nearest:NO] != rewindPage)
+        [self doRewind];
+}
+
+- (void)doFinalRewind {
+    if (rewindPage && [[self currentPage] isEqual:rewindPage] == NO)
+        [self doRewind];
+    rewindPage = nil;
+}
+
 - (BOOL)needsRewind {
     return rewindPage != nil;
 }
 
 - (void)setNeedsRewind:(BOOL)flag {
+    [[self class] cancelPreviousPerformRequestsWithTarget:self 
selector:@selector(doInitialRewind) object:nil];
+    [[self class] cancelPreviousPerformRequestsWithTarget:self 
selector:@selector(doFinalRewind) object:nil];
     if (flag) {
         rewindPage = [self currentPage];
-        DISPATCH_MAIN_AFTER_SEC(0.0, ^{
-            if (rewindPage && [self pageForPoint:SKCenterPoint([self 
unobscuredContentRect]) nearest:NO] != rewindPage)
-                [self doRewind];
-        });
-        DISPATCH_MAIN_AFTER_SEC(0.25, ^{
-            if (rewindPage) {
-                if ([[self currentPage] isEqual:rewindPage] == NO)
-                    [self doRewind];
-                rewindPage = nil;
-            }
-        });
+        [self performSelector:@selector(doInitialRewind) withObject:nil 
afterDelay:0.0];
+        [self performSelector:@selector(doFinalRewind) withObject:nil 
afterDelay:0.25];
     } else {
         rewindPage = nil;
     }

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