Revision: 16757
          http://sourceforge.net/p/skim-app/code/16757
Author:   hofman
Date:     2026-10-31 15:04:09 +0000 (Sat, 31 Oct 2026)
Log Message:
-----------
cache fileURLToOpen

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

Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m  2026-10-30 22:51:46 UTC (rev 16756)
+++ trunk/SKBookmark.m  2026-10-31 15:04:09 UTC (rev 16757)
@@ -527,10 +527,10 @@
 }
 
 - (NSURL *)fileURL {
-    if (cachedFileURL)
-        return [cachedFileURL isEqual:[NSNull null]] ? nil : cachedFileURL;
-    cachedFileURL = [alias fileURLNoUI] ?: (id)[NSNull null];
-    if (cachedFileURL) {
+    NSURL *fileURL = nil;
+    if (cachedFileURL == nil) {
+        fileURL = [alias fileURLNoUI];
+        cachedFileURL = fileURL ?: (id)[NSNull null];
         __weak typeof(self) weakSelf = self;
         dispatch_async(dispatch_get_main_queue(), ^{
             __strong typeof(self) strongSelf = weakSelf;
@@ -537,8 +537,10 @@
             if (strongSelf)
                 strongSelf->cachedFileURL = nil;
         });
+    } else if ([cachedFileURL isEqual:[NSNull null]] == NO) {
+        fileURL = cachedFileURL;
     }
-    return cachedFileURL;
+    return fileURL;
 }
 
 - (void)setFileURL:(NSURL *)fileURL {
@@ -550,9 +552,25 @@
 }
 
 - (NSURL *)fileURLToOpen {
-    if (cachedFileURL && [cachedFileURL isEqual:[NSNull null]] == NO)
-        return cachedFileURL;
-    return [alias fileURL];
+    NSURL *fileURL = nil;
+    if (cachedFileURL && [cachedFileURL isEqual:[NSNull null]] == NO) {
+        fileURL = cachedFileURL;
+    } else {
+        fileURL = [alias fileURL];
+        if (cachedFileURL == nil) {
+            __weak typeof(self) weakSelf = self;
+            dispatch_async(dispatch_get_main_queue(), ^{
+                __strong typeof(self) strongSelf = weakSelf;
+                if (strongSelf)
+                    strongSelf->cachedFileURL = nil;
+            });
+        }
+        if (fileURL)
+            cachedFileURL = fileURL;
+        else if (cachedFileURL == nil)
+            cachedFileURL = (id)[NSNull null];
+    }
+    return fileURL;
 }
 
 - (NSString *)fileDescription {

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