Revision: 13986
          http://sourceforge.net/p/skim-app/code/13986
Author:   hofman
Date:     2023-12-25 14:57:21 +0000 (Mon, 25 Dec 2023)
Log Message:
-----------
correct check for download containment, reorder update statements

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

Modified: trunk/SKDownloadController.m
===================================================================
--- trunk/SKDownloadController.m        2023-12-25 10:41:24 UTC (rev 13985)
+++ trunk/SKDownloadController.m        2023-12-25 14:57:21 UTC (rev 13986)
@@ -233,9 +233,11 @@
     [tableView beginUpdates];
     [tableView insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:anIndex] 
withAnimation:options];
     [downloads insertObject:download atIndex:anIndex];
+    [tableView endUpdates];
+    
     [self startObservingDownloads:@[download]];
     [download start];
-    [tableView endUpdates];
+    
     [self updateClearButton];
 }
 
@@ -243,6 +245,7 @@
     NSArray *oldDownloads = [downloads objectsAtIndexes:indexes];
     [self endObservingDownloads:oldDownloads];
     [oldDownloads makeObjectsPerformSelector:@selector(cancel)];
+    
     NSTableViewAnimationOptions options = NSTableViewAnimationEffectGap | 
NSTableViewAnimationSlideUp;
     if ([self isWindowLoaded] == NO || [[self window] isVisible] == NO || 
[NSView shouldShowSlideAnimation] == NO)
         options = NSTableViewAnimationEffectNone;
@@ -250,6 +253,7 @@
     [tableView removeRowsAtIndexes:indexes withAnimation:options];
     [downloads removeObjectsAtIndexes:indexes];
     [tableView endUpdates];
+    
     [self updateClearButton];
 }
 
@@ -535,8 +539,7 @@
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change context:(void *)context {
     if (context == &SKDownloadPropertiesObservationContext) {
-        NSUInteger row = [downloads containsObject:object];
-        if (row != NSNotFound) {
+        if ([downloads containsObject:object]) {
             if ([keyPath isEqualToString:SKDownloadFileURLKey]) {
                 [tableView reloadTypeSelectStrings];
             } else if ([keyPath isEqualToString:SKDownloadStatusKey]) {
@@ -544,7 +547,7 @@
                 [self setTouchBar:nil];
                 if ([object status] == SKDownloadStatusFinished) {
                     [self openDownload:object];
-                    if ([QLPreviewPanel sharedPreviewPanelExists] && 
[[QLPreviewPanel sharedPreviewPanel] isVisible] && [[QLPreviewPanel 
sharedPreviewPanel] dataSource] == self && [tableView isRowSelected:row])
+                    if ([QLPreviewPanel sharedPreviewPanelExists] && 
[[QLPreviewPanel sharedPreviewPanel] isVisible] && [[QLPreviewPanel 
sharedPreviewPanel] dataSource] == self && [tableView isRowSelected:[downloads 
indexOfObject:object]])
                         [[QLPreviewPanel sharedPreviewPanel] reloadData];
                 }
             }

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