Revision: 14307
          http://sourceforge.net/p/skim-app/code/14307
Author:   hofman
Date:     2024-06-06 14:54:22 +0000 (Thu, 06 Jun 2024)
Log Message:
-----------
setNeedsUpdate method instead of dirty property for thumbnails, always 
initialize dirty

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

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-06-05 23:15:57 UTC (rev 14306)
+++ trunk/SKMainWindowController.m      2024-06-06 14:54:22 UTC (rev 14307)
@@ -2889,9 +2889,7 @@
     if ([pageLabels count] > 0) {
         NSImage *pageImage = [self placeholderThumbnailImage];
         [pageLabels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger 
i, BOOL *stop) {
-            SKThumbnail *thumbnail = [[SKThumbnail alloc] 
initWithImage:pageImage label:label pageIndex:i];
-            [thumbnail setDirty:YES];
-            [newThumbnails addObject:thumbnail];
+            [newThumbnails addObject:[[SKThumbnail alloc] 
initWithImage:pageImage label:label pageIndex:i]];
         }];
     }
     // reloadData resets the selection, so we have to ignore its notification 
and reset it
@@ -2926,15 +2924,15 @@
 }
 
 - (void)updateThumbnailAtPageIndex:(NSUInteger)anIndex {
-    [[thumbnails objectAtIndex:anIndex] setDirty:YES];
+    [[thumbnails objectAtIndex:anIndex] setNeedsUpdate];
 }
 
 - (void)updateThumbnailsAtPageIndexes:(NSIndexSet *)indexSet {
-    [[thumbnails objectsAtIndexes:indexSet] setValue:@YES forKey:@"dirty"];
+    [[thumbnails objectsAtIndexes:indexSet] 
makeObjectsPerformSelector:@selector(setNeedsUpdate)];
 }
 
 - (void)allThumbnailsNeedUpdate {
-    [thumbnails setValue:@YES forKey:@"dirty"];
+    [thumbnails makeObjectsPerformSelector:@selector(setNeedsUpdate)];
 }
 
 #pragma mark Notes

Modified: trunk/SKThumbnail.h
===================================================================
--- trunk/SKThumbnail.h 2024-06-05 23:15:57 UTC (rev 14306)
+++ trunk/SKThumbnail.h 2024-06-06 14:54:22 UTC (rev 14307)
@@ -48,12 +48,11 @@
     NSImage *image;
     NSString *label;
     NSUInteger pageIndex;
-    BOOL dirty;
+    BOOL needsUpdate;
     __weak id <SKThumbnailDelegate> delegate;
 }
 
 @property (nonatomic, nullable, weak) id <SKThumbnailDelegate> delegate;
-@property (nonatomic, getter=isDirty) BOOL dirty;
 @property (nonatomic, strong) NSImage *image;
 @property (nonatomic, strong) NSString *label;
 @property (nonatomic, readonly) NSUInteger pageIndex;
@@ -62,6 +61,8 @@
 
 - (instancetype)initWithImage:(NSImage *)anImage label:(NSString *)aLabel 
pageIndex:(NSUInteger)anIndex;
 
+- (void)setNeedsUpdate;
+
 @end
 
 

Modified: trunk/SKThumbnail.m
===================================================================
--- trunk/SKThumbnail.m 2024-06-05 23:15:57 UTC (rev 14306)
+++ trunk/SKThumbnail.m 2024-06-06 14:54:22 UTC (rev 14307)
@@ -41,7 +41,7 @@
 
 @implementation SKThumbnail
 
-@synthesize delegate, dirty, image, label, pageIndex;
+@synthesize delegate, image, label, pageIndex;
 @dynamic size, page;
 
 - (instancetype)initWithImage:(NSImage *)anImage label:(NSString *)aLabel 
pageIndex:(NSUInteger)anIndex {
@@ -50,14 +50,14 @@
         image = anImage;
         label = aLabel;
         pageIndex = anIndex;
-        dirty = NO;
+        needsUpdate = YES;
     }
     return self;
 }
 
 - (NSImage *)image {
-    if (dirty && [delegate generateImageForThumbnail:self])
-        dirty = NO;
+    if (needsUpdate && [delegate generateImageForThumbnail:self])
+        needsUpdate = NO;
     return image;
 }
 
@@ -69,9 +69,9 @@
     return [delegate pageForThumbnail:self];
 }
 
-- (void)setDirty:(BOOL)newDirty {
+- (void)setNeedsUpdate {
     [self willChangeValueForKey:@"image"];
-    dirty = newDirty;
+    needsUpdate = YES;
     [self didChangeValueForKey:@"image"];
 }
 

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