Revision: 14317
          http://sourceforge.net/p/skim-app/code/14317
Author:   hofman
Date:     2024-06-08 21:53:36 +0000 (Sat, 08 Jun 2024)
Log Message:
-----------
ignore snapshot thumbnail updates that were delayed

Modified Paths:
--------------
    trunk/SKMainWindowController.m
    trunk/SKSnapshotWindowController.h
    trunk/SKSnapshotWindowController.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-06-08 18:02:48 UTC (rev 14316)
+++ trunk/SKMainWindowController.m      2024-06-08 21:53:36 UTC (rev 14317)
@@ -3028,6 +3028,7 @@
 - (void)snapshotNeedsUpdate:(SKSnapshotWindowController *)controller {
     CGFloat backingScale = [[self window] backingScaleFactor];
     SKSnapshotConfiguration *configuration = [controller currentConfiguration];
+    NSDate *date = [NSDate date];
     dispatch_queue_t queue;
     
     if ([rightSideController.snapshotTableView window])
@@ -3040,6 +3041,10 @@
         NSImage *image = [configuration thumbnailWithSize:snapshotCacheSize 
scale:backingScale];
         
         dispatch_async(dispatch_get_main_queue(), ^{
+            // ignore this thumbnail when a later update was set earlier, e.g. 
from a higher priority
+            if ([[controller updateDate] compare:date] == NSOrderedDescending)
+                return;
+            
             NSSize newSize = [image size];
             NSSize oldSize = [[controller thumbnail] size];
             
@@ -3046,6 +3051,7 @@
             [image setAccessibilityDescription:[NSString 
stringWithFormat:NSLocalizedString(@"Page %@", @""), [controller pageLabel]]];
             
             [controller setThumbnail:image];
+            [controller setUpdateDate:date];
             
             if (fabs(newSize.width - oldSize.width) > 1.0 || 
fabs(newSize.height - oldSize.height) > 1.0) {
                 NSUInteger idx = [[rightSideController.snapshotArrayController 
arrangedObjects] indexOfObject:controller];

Modified: trunk/SKSnapshotWindowController.h
===================================================================
--- trunk/SKSnapshotWindowController.h  2024-06-08 18:02:48 UTC (rev 14316)
+++ trunk/SKSnapshotWindowController.h  2024-06-08 21:53:36 UTC (rev 14317)
@@ -55,6 +55,7 @@
 @interface SKSnapshotWindowController : NSWindowController <NSWindowDelegate, 
NSFilePromiseProviderDelegate, SKSnapshotPDFViewDelegate> {
     SKSnapshotPDFView* pdfView;
     NSImage *thumbnail;
+    NSDate *updateDate;
     __weak id <SKSnapshotWindowControllerDelegate> delegate;
     NSString *pageLabel;
     NSString *string;
@@ -66,6 +67,7 @@
 @property (nonatomic, nullable, strong) IBOutlet SKSnapshotPDFView *pdfView;
 @property (nonatomic, nullable, weak) id <SKSnapshotWindowControllerDelegate> 
delegate;
 @property (nonatomic, nullable, strong) NSImage *thumbnail;
+@property (nonatomic, nullable, strong) NSDate *updateDate;
 @property (nonatomic, readonly) NSRect bounds;
 @property (nonatomic, readonly) NSUInteger pageIndex;
 @property (nonatomic, nullable, readonly, copy) NSString *pageLabel;

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2024-06-08 18:02:48 UTC (rev 14316)
+++ trunk/SKSnapshotWindowController.m  2024-06-08 21:53:36 UTC (rev 14317)
@@ -92,7 +92,7 @@
 
 @implementation SKSnapshotWindowController
 
-@synthesize pdfView, delegate, thumbnail, pageLabel, string, hasWindow, 
forceOnTop, currentConfiguration;
+@synthesize pdfView, delegate, thumbnail, updateDate, pageLabel, string, 
hasWindow, forceOnTop, currentConfiguration;
 @dynamic bounds, pageIndex, currentSetup, thumbnailAttachment, 
thumbnail512Attachment, thumbnail256Attachment, thumbnail128Attachment, 
thumbnail64Attachment, thumbnail32Attachment;
 
 - (NSString *)windowNibName {

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