Revision: 28626
          http://sourceforge.net/p/bibdesk/svn/28626
Author:   hofman
Date:     2024-01-17 10:41:02 +0000 (Wed, 17 Jan 2024)
Log Message:
-----------
return URL with retain count 1 to avoid autorelease dance

Modified Paths:
--------------
    trunk/bibdesk/BDSKComplexString.m
    trunk/bibdesk/BDSKLinkedFile.m

Modified: trunk/bibdesk/BDSKComplexString.m
===================================================================
--- trunk/bibdesk/BDSKComplexString.m   2024-01-16 19:15:30 UTC (rev 28625)
+++ trunk/bibdesk/BDSKComplexString.m   2024-01-17 10:41:02 UTC (rev 28626)
@@ -218,7 +218,7 @@
 }
 
 static inline
-BOOL __BDStringNodesMatch(NSArray *sourceNodes, NSArray *targetNodes, 
NSUInteger opts, NSUInteger idx, NSString **prefix, NSString **suffix) {
+BOOL __BDStringNodesMatch(NSArray *sourceNodes, NSArray *targetNodes, 
NSStringCompareOptions opts, NSUInteger idx, NSString **prefix, NSString 
**suffix) {
     NSUInteger i, tNum = [targetNodes count];
     
     for (i = 0; i < tNum; i++) {

Modified: trunk/bibdesk/BDSKLinkedFile.m
===================================================================
--- trunk/bibdesk/BDSKLinkedFile.m      2024-01-16 19:15:30 UTC (rev 28625)
+++ trunk/bibdesk/BDSKLinkedFile.m      2024-01-17 10:41:02 UTC (rev 28626)
@@ -54,7 +54,7 @@
 #define BOOKMARK_KEY @"bookmark"
 #define RELATIVEPATH_KEY @"relativePath"
 
-static NSURL *BDSKURLFromFSRef(const FSRef *inRef);
+static NSURL *BDSKCreateURLFromFSRef(const FSRef *inRef);
 static BOOL BDSKPathToFSRef(NSString *inPath, FSRef *outRef);
 static NSDictionary *BDSKDictionaryFromPlistData(NSData *data);
 static NSDictionary *BDSKDictionaryFromArchivedData(NSData *data);
@@ -637,7 +637,7 @@
     }
     
     if ((shouldUpdate || fileURL == nil) && fileRef != nil) {
-        NSURL *aURL = BDSKURLFromFSRef(fileRef);
+        NSURL *aURL = BDSKCreateURLFromFSRef(fileRef);
         if (aURL != nil) {
             if (fileURL == nil)
                 fileURL = aURL;
@@ -654,7 +654,7 @@
     NSURL *aURL = nil;
     
     if (fileRef != nil) {
-        aURL = BDSKURLFromFSRef(fileRef);
+        aURL = BDSKCreateURLFromFSRef(fileRef);
         if (aURL == nil && fileRef) {
             // fileRef was invalid, try to update it
             free((void *)fileRef);
@@ -664,7 +664,7 @@
     if (aURL == nil) {
         // fileRef was nil or invalid
         [self updateFileRef];
-        aURL = BDSKURLFromFSRef(fileRef);
+        aURL = BDSKCreateURLFromFSRef(fileRef);
     }
     
     if ([aURL isEqual:fileURL] == NO && (aURL != nil || hadFileURL)) {
@@ -673,7 +673,7 @@
             // the file was replaced, reference the replacement rather than 
the moved file
             // this is what Dropbox does with file updates
             [self setFileRef:&aRef];
-            aURL = BDSKURLFromFSRef(fileRef);
+            aURL = BDSKCreateURLFromFSRef(fileRef);
             NSString *basePath = [delegate basePathForLinkedFile:self];
             FSRef baseRef;
             if (BDSKPathToFSRef(basePath, &baseRef)) {
@@ -707,7 +707,7 @@
         // this does the updating if possible
         [self updateFileRef];
     } else {
-        NSURL *aURL = BDSKURLFromFSRef(fileRef);
+        NSURL *aURL = BDSKCreateURLFromFSRef(fileRef);
         if (aURL != nil) {
             // if the path has changed, updating will be done below
             if (basePath && (aPath == nil || [[aURL path] 
isEqualToString:aPath])) {
@@ -738,7 +738,7 @@
             BOOL needsUpdate = YES;
             FSRef aRef;
             if (BDSKPathToFSRef(aPath, &aRef)) {
-                NSURL *aURL = BDSKURLFromFSRef(&aRef);
+                NSURL *aURL = BDSKCreateURLFromFSRef(&aRef);
                 if ([path isEqualToString:[aURL path]]) {
                     needsUpdate = NO;
                 } else {
@@ -762,7 +762,6 @@
 
 - (NSData *)copyAliasDataRelativeToPath:(NSString *)basePath {
     BDSKAlias *anAlias = NULL;
-    NSData *data = nil;
     
     if (fileRef) {
         FSRef baseRef;
@@ -772,13 +771,10 @@
         NSString *path = [relativePath isAbsolutePath] ? relativePath : 
[[basePath stringByAppendingPathComponent:relativePath] 
stringByStandardizingPath];
         anAlias = [BDSKAlias newWithPath:path basePath:basePath];
     }
-    if (anAlias != NULL) {
-        data = [anAlias copyData];
-    } else if ([alias isKindOfClass:[BDSKAlias class]]) {
-        data = [alias copyData];
-    }
+    if (anAlias == NULL && [alias isKindOfClass:[BDSKAlias class]])
+        anAlias = alias;
     
-    return data;
+    return [anAlias copyData];
 }
 
 - (NSData *)copyDataRelativeToPath:(NSString *)newBasePath isBookmark:(BOOL 
*)isBookmark {
@@ -867,7 +863,7 @@
             FSRef aRef, baseRef;
             BOOL ignored, hasBaseRef = BDSKPathToFSRef(basePath, &baseRef);
             if ([alias getFSRef:&aRef baseRef:hasBaseRef ? &baseRef : NULL 
shouldUpdate:&ignored]){
-                aURL = BDSKURLFromFSRef(&aRef);
+                aURL = BDSKCreateURLFromFSRef(&aRef);
                 if (aURL)
                     refURL = [aURL fileReferenceURL];
             }
@@ -946,13 +942,10 @@
         NSString *path = [relativePath isAbsolutePath] ? relativePath : 
[[basePath stringByAppendingPathComponent:relativePath] 
stringByStandardizingPath];
         anAlias = [BDSKAlias newWithPath:path basePath:basePath];
     }
-    if (anAlias != NULL) {
-        data = [anAlias copyData];
-    } else if ([alias isKindOfClass:[BDSKAlias class]]) {
-        data = [alias copyData];
-    }
+    if (anAlias != NULL && [alias isKindOfClass:[BDSKAlias class]])
+        anAlias = alias;
     
-    return data;
+    return [anAlias copyData];
 }
 
 - (NSData *)copyDataRelativeToPath:(NSString *)newBasePath isBookmark:(BOOL 
*)isBookmark {
@@ -1047,7 +1040,7 @@
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
 
-static NSURL *BDSKURLFromFSRef(const FSRef *inRef) {
+static NSURL *BDSKCreateURLFromFSRef(const FSRef *inRef) {
     return inRef == NULL ? NULL : CFBridgingRelease(CFURLCreateFromFSRef(NULL, 
inRef));
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to