Revision: 16388
          http://sourceforge.net/p/skim-app/code/16388
Author:   hofman
Date:     2026-07-10 16:38:38 +0000 (Fri, 10 Jul 2026)
Log Message:
-----------
Load thumbnails after sizing the page columns to fit, for some reason 
NSTableView.sizeToFit crashes with certain (number of) thumbnails. Don't mark 
thumbnails for locked pdf as needing display, they will be reset when unlocking.

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

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2026-07-10 14:42:16 UTC (rev 16387)
+++ trunk/SKMainWindowController.m      2026-07-10 16:38:38 UTC (rev 16388)
@@ -853,16 +853,18 @@
     
     [self updatePageLabel];
     
-    // these carry a label, moreover when this is called the thumbnails will 
also be invalid
-    [self resetThumbnails];
+    // these carry a label
     [rightSideController.noteOutlineView reloadData];
     
-    if (changed) {
-        [leftSideController.thumbnailTableView reloadTypeSelectStrings];
-
+    // when this is called the thumbnails will also be invalid
+    if (changed)
         [self updatePageColumnWidthForTableViews:[[leftSideController 
tableViews] arrayByAddingObjectsFromArray:[rightSideController tableViews]]];
-    }
     
+    // sizeToFit sometimes crashes with certain thumbnails (?), so reload 
after resizing the columns
+    [self resetThumbnails];
+    if (changed)
+        [leftSideController.thumbnailTableView reloadTypeSelectStrings];
+    
     PDFOutline *outlineRoot = [[pdfView document] outlineRoot];
     
     // layout of cellview in column: |-(18+(level-1)*indentation)-[label]-(10 
or 2)-|
@@ -2993,6 +2995,8 @@
         [pageLabels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger 
i, BOOL *stop) {
             [newThumbnails addObject:[[SKThumbnail alloc] 
initWithImage:pageImage label:label pageIndex:i]];
         }];
+        if ([[pdfView document] isLocked])
+            [newThumbnails setValue:@NO forKey:@"needsUpdate"];
     }
     // reloadData resets the selection, so we have to ignore its notification 
and reset it
     mwcFlags.updatingThumbnailSelection = 1;
@@ -3025,15 +3029,15 @@
 }
 
 - (void)updateThumbnailAtPageIndex:(NSUInteger)anIndex {
-    [[thumbnails objectAtIndex:anIndex] setNeedsUpdate];
+    [[thumbnails objectAtIndex:anIndex] setNeedsUpdate:YES];
 }
 
 - (void)updateThumbnailsAtPageIndexes:(NSIndexSet *)indexSet {
-    [[thumbnails objectsAtIndexes:indexSet] 
makeObjectsPerformSelector:@selector(setNeedsUpdate)];
+    [[thumbnails objectsAtIndexes:indexSet] setValue:@YES 
forKey:@"needsUpdate"];
 }
 
 - (void)allThumbnailsNeedUpdate {
-    [thumbnails makeObjectsPerformSelector:@selector(setNeedsUpdate)];
+    [thumbnails setValue:@YES forKey:@"needsUpdate"];
 }
 
 #pragma mark Notes

Modified: trunk/SKThumbnail.h
===================================================================
--- trunk/SKThumbnail.h 2026-07-10 14:42:16 UTC (rev 16387)
+++ trunk/SKThumbnail.h 2026-07-10 16:38:38 UTC (rev 16388)
@@ -59,13 +59,12 @@
 @property (nonatomic, readonly) NSUInteger pageIndex;
 @property (nonatomic, readonly) NSSize size;
 @property (nonatomic, nullable, readonly) PDFPage *page;
+@property (nonatomic) BOOL needsUpdate;
 @property (nonatomic, readonly, getter=isPlaceholder) BOOL placeholder;
 
 - (instancetype)initWithImage:(NSImage *)anImage label:(NSString *)aLabel 
pageIndex:(NSUInteger)anIndex NS_DESIGNATED_INITIALIZER;
 - (instancetype)init NS_UNAVAILABLE;
 
-- (void)setNeedsUpdate;
-
 @end
 
 

Modified: trunk/SKThumbnail.m
===================================================================
--- trunk/SKThumbnail.m 2026-07-10 14:42:16 UTC (rev 16387)
+++ trunk/SKThumbnail.m 2026-07-10 16:38:38 UTC (rev 16388)
@@ -41,7 +41,7 @@
 
 @implementation SKThumbnail
 
-@synthesize delegate, label, pageIndex, placeholder;
+@synthesize delegate, label, pageIndex, needsUpdate, placeholder;
 @dynamic image, size, page;
 
 - (instancetype)initWithImage:(NSImage *)anImage label:(NSString *)aLabel 
pageIndex:(NSUInteger)anIndex {
@@ -85,10 +85,14 @@
     }
 }
 
-- (void)setNeedsUpdate {
-    [self willChangeValueForKey:@"image"];
-    needsUpdate = YES;
-    [self didChangeValueForKey:@"image"];
+- (void)setNeedsUpdate:(BOOL)flag {
+    if (flag) {
+        [self willChangeValueForKey:@"image"];
+        needsUpdate = YES;
+        [self didChangeValueForKey:@"image"];
+    } else {
+        needsUpdate = NO;
+    }
 }
 
 @end

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