Revision: 28513
          http://sourceforge.net/p/bibdesk/svn/28513
Author:   hofman
Date:     2024-01-03 10:44:11 +0000 (Wed, 03 Jan 2024)
Log Message:
-----------
Add some CFBridgingRelease and a few more __bridge

Modified Paths:
--------------
    trunk/bibdesk/BDSKDocumentSearch.m
    trunk/bibdesk/BDSKFileMatcher.m
    trunk/bibdesk/BDSKFileSearch.m
    trunk/bibdesk/BDSKFileSearchIndex.m
    trunk/bibdesk/BDSKItemPasteboardHelper.h
    trunk/bibdesk/BDSKItemPasteboardHelper.m
    trunk/bibdesk/BDSKItemSearchIndexes.m
    trunk/bibdesk/BDSKLinkedFile.m
    trunk/bibdesk/BDSKNotesSearchIndex.m
    trunk/bibdesk/BDSKPersistentSearch.m
    trunk/bibdesk/BDSKSearchGroup.h
    trunk/bibdesk/BDSKSearchGroup.m
    trunk/bibdesk/BDSKWebGroup.h
    trunk/bibdesk/BDSKWebGroup.m
    trunk/bibdesk/BDSKWebViewModalDialogController.h
    trunk/bibdesk/BDSKWebViewModalDialogController.m
    trunk/bibdesk/NSString_BDSKExtensions.m

Modified: trunk/bibdesk/BDSKDocumentSearch.m
===================================================================
--- trunk/bibdesk/BDSKDocumentSearch.m  2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKDocumentSearch.m  2024-01-03 10:44:11 UTC (rev 28513)
@@ -130,7 +130,7 @@
     
     // note that the add/remove methods flush the index, so we don't have to 
do it again
     NSParameterAssert(NULL == search);
-    search = SKSearchCreate(skIndex, (CFStringRef)searchString, 
kSKSearchOptionDefault);
+    search = SKSearchCreate(skIndex, (__bridge CFStringRef)searchString, 
kSKSearchOptionDefault);
     
     SKDocumentID documents[SEARCH_BUFFER_MAX] = { 0 };
     float scores[SEARCH_BUFFER_MAX] = { 0.0 };
@@ -149,7 +149,7 @@
         if (foundCount > 0) {
             
             NSParameterAssert(foundCount <= SEARCH_BUFFER_MAX);
-            id documentURLs[SEARCH_BUFFER_MAX] = { nil };
+            CFURLRef documentURLs[SEARCH_BUFFER_MAX] = { nil };
             SKIndexCopyDocumentURLsForDocumentIDs(skIndex, foundCount, 
documents, (CFURLRef *)documentURLs);
             foundURLSet = [NSMutableSet setWithCapacity:foundCount];
             
@@ -156,10 +156,10 @@
             for (i = 0; i < foundCount; i++) {
                 
                 // Array may contain NULL values from initialization; before 
adding the initialization step, it was possible to pass garbage pointers as 
documentURL (bug #2124370) and non-finite values for the score (bug #1932040).  
This is actually a gap in the returned values, so appears to be a Search Kit 
bug.
-                if (documentURLs[i] != nil) {
-                    [originalScores setObject:[NSNumber 
numberWithDouble:scores[i]] forKey:documentURLs[i]];
-                    [foundURLSet addObject:documentURLs[i]];
-                    [documentURLs[i] release];
+                if (documentURLs[i] != NULL) {
+                    [originalScores setObject:[NSNumber 
numberWithDouble:scores[i]] forKey:(__bridge NSURL *)documentURLs[i]];
+                    [foundURLSet addObject:(__bridge NSURL *)documentURLs[i]];
+                    CFRelease(documentURLs[i]);
                     maxScore = MAX(maxScore, scores[i]);
                 }
             }

Modified: trunk/bibdesk/BDSKFileMatcher.m
===================================================================
--- trunk/bibdesk/BDSKFileMatcher.m     2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKFileMatcher.m     2024-01-03 10:44:11 UTC (rev 28513)
@@ -468,7 +468,7 @@
         
         NSString *searchString = [node valueForKey:SEARCHSTRING_KEY];
         
-        SKSearchRef search = SKSearchCreate(searchIndex, 
(CFStringRef)searchString, kSKSearchOptionDefault);
+        SKSearchRef search = SKSearchCreate(searchIndex, (__bridge 
CFStringRef)searchString, kSKSearchOptionDefault);
         
         // if we get more than 10 matches back per pub, the results will be 
pretty useless anyway
         SKDocumentID docID[MAX_SEARCHKIT_RESULTS];
@@ -494,9 +494,9 @@
                 // now we have a matching file; we could remove it from the 
index, but multiple matches are reasonable
                 for (i =  0; i < iMax; i++) {
                     BDSKTreeNode *child = [[BDSKTreeNode alloc] init];
-                    [child setValue:(id)urls[i] forKey:FILEURL_KEY];
-                    [child setValue:[[(id)urls[i] path] 
stringByAbbreviatingWithTildeInPath] forKey:STRING_KEY];
-                    [child setValue:[[NSWorkspace sharedWorkspace] 
iconForFile:[(NSURL *)urls[i] path]] forKey:IMAGE_KEY];
+                    [child setValue:(__bridge NSURL *)urls[i] 
forKey:FILEURL_KEY];
+                    [child setValue:[[(__bridge NSURL *)urls[i] path] 
stringByAbbreviatingWithTildeInPath] forKey:STRING_KEY];
+                    [child setValue:[[NSWorkspace sharedWorkspace] 
iconForFile:[(__bridge NSURL *)urls[i] path]] forKey:IMAGE_KEY];
                     [child setValue:searchString forKey:SEARCHSTRING_KEY];
                     thisScore = scores[i];
                     maxScore = MAX(maxScore, thisScore);
@@ -551,7 +551,7 @@
     CFMutableDictionaryRef opts = CFDictionaryCreateMutable(NULL, 0, 
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
     
     // we generally shouldn't need to index the (default) first 2000 terms 
just to get title and author
-    CFDictionaryAddValue(opts, kSKMaximumTerms, (CFNumberRef)@200);
+    CFDictionaryAddValue(opts, kSKMaximumTerms, (__bridge CFNumberRef)@200);
     
     // kSKProximityIndexing is unused for now, since it slows things down and 
caused a crash on one of my files rdar://problem/4988691 (fixed in 10.5)
     CFDictionaryAddValue(opts, kSKProximityIndexing, kCFBooleanTrue);
@@ -578,7 +578,7 @@
     for (NSURL *url in fileURLs) {
         if (atomic_load(&_matchFlags.shouldAbort)) break;
         
-        SKDocumentRef doc = SKDocumentCreateWithURL((CFURLRef)url);
+        SKDocumentRef doc = SKDocumentCreateWithURL((__bridge CFURLRef)url);
         
         if (shouldLog)
             NSLog(@"%@", url);

Modified: trunk/bibdesk/BDSKFileSearch.m
===================================================================
--- trunk/bibdesk/BDSKFileSearch.m      2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKFileSearch.m      2024-01-03 10:44:11 UTC (rev 28513)
@@ -179,7 +179,7 @@
         return;
     }
         
-    SKSearchRef skSearch = SKSearchCreate(skIndex, (CFStringRef)searchString, 
options);
+    SKSearchRef skSearch = SKSearchCreate(skIndex, (__bridge 
CFStringRef)searchString, options);
     [self setSearch:skSearch];
     CFRelease(skSearch);
     
@@ -227,7 +227,7 @@
             // these scores are arbitrarily scaled, so we'll keep track of the 
search kit's max/min values
             maxValue = MAX(score, maxValue);
             
-            NSURL *theURL = (NSURL *)SKDocumentCopyURL(skDocument);
+            NSURL *theURL = CFBridgingRelease(SKDocumentCopyURL(skDocument));
             NSSet *identifierURLs = [searchIndex identifierURLsForURL:theURL];
             NSString *title = nil;
             
@@ -237,7 +237,6 @@
                 [searchResults addObject:searchResult];            
                 [searchResult release];
             }
-            [theURL release];            
             CFRelease(skDocument);
         }      
         

Modified: trunk/bibdesk/BDSKFileSearchIndex.m
===================================================================
--- trunk/bibdesk/BDSKFileSearchIndex.m 2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKFileSearchIndex.m 2024-01-03 10:44:11 UTC (rev 28513)
@@ -372,7 +372,7 @@
     if ([[signatures objectForKey:aURL] isEqual:signature] == NO) {
         // either the file was not indexed, or it has changed
         
-        SKDocumentRef skDocument = SKDocumentCreateWithURL((CFURLRef)aURL);
+        SKDocumentRef skDocument = SKDocumentCreateWithURL((__bridge 
CFURLRef)aURL);
         
         BDSKPOSTCONDITION(skDocument);
         
@@ -388,7 +388,7 @@
 }
 
 - (void)removeFileURL:(NSURL *)aURL{
-    SKDocumentRef skDocument = SKDocumentCreateWithURL((CFURLRef)aURL);
+    SKDocumentRef skDocument = SKDocumentCreateWithURL((__bridge 
CFURLRef)aURL);
     
     BDSKPOSTCONDITION(skDocument);
     
@@ -558,8 +558,8 @@
     
     if (tmpIndex == NULL) {
         indexData = CFDataCreateMutable(CFAllocatorGetDefault(), 0);
-        NSDictionary *options = @{(id)kSKMaximumTerms:@0, 
(id)kSKMinTermLength:@3};
-        tmpIndex = SKIndexCreateWithMutableData(indexData, NULL, 
kSKIndexInverted, (CFDictionaryRef)options);
+        NSDictionary *options = @{(__bridge id)kSKMaximumTerms:@0, (__bridge 
id)kSKMinTermLength:@3};
+        tmpIndex = SKIndexCreateWithMutableData(indexData, NULL, 
kSKIndexInverted, (__bridge CFDictionaryRef)options);
     }
     
     skIndex = tmpIndex;

Modified: trunk/bibdesk/BDSKItemPasteboardHelper.h
===================================================================
--- trunk/bibdesk/BDSKItemPasteboardHelper.h    2024-01-02 16:57:48 UTC (rev 
28512)
+++ trunk/bibdesk/BDSKItemPasteboardHelper.h    2024-01-03 10:44:11 UTC (rev 
28513)
@@ -55,6 +55,7 @@
     BDSKTeXTask *texTask;
     NSInteger generatorCount;
     __weak id<BDSKItemPasteboardHelperDelegate> delegate;
+    id strongSelf;
 }
 
 @property (nonatomic, weak) id <BDSKItemPasteboardHelperDelegate> delegate;

Modified: trunk/bibdesk/BDSKItemPasteboardHelper.m
===================================================================
--- trunk/bibdesk/BDSKItemPasteboardHelper.m    2024-01-02 16:57:48 UTC (rev 
28512)
+++ trunk/bibdesk/BDSKItemPasteboardHelper.m    2024-01-03 10:44:11 UTC (rev 
28513)
@@ -277,7 +277,7 @@
             promisedPboardTypes = [[NSMutableDictionary alloc] 
initWithCapacity:2];
             // we should stay around as pboard owner until all types are 
delivered or cleared
             // we use promisedPboardTypes != nil to signal that we retain 
ourselves
-            [self retain];
+            strongSelf = [self retain];
         }
         [promisedPboardTypes setObject:dict forKey:[pboard name]];
         if ([types count] > 1 && pboard == [NSPasteboard generalPasteboard])
@@ -330,7 +330,7 @@
             promisedPboardTypes = nil;
             // we used promisedPboardTypes != nil to signal we retained 
ourselves
             // see setPromisedTypes:items:dragCopyType:forPasteboard:
-            [self autorelease];
+            BDSKDESTROY(strongSelf);
         }
     }
 }

Modified: trunk/bibdesk/BDSKItemSearchIndexes.m
===================================================================
--- trunk/bibdesk/BDSKItemSearchIndexes.m       2024-01-02 16:57:48 UTC (rev 
28512)
+++ trunk/bibdesk/BDSKItemSearchIndexes.m       2024-01-03 10:44:11 UTC (rev 
28513)
@@ -93,7 +93,7 @@
 
 - (void)addPublications:(NSArray *)pubs forFields:(NSSet *)fields {
     for (BibItem *pub in pubs) {
-        SKDocumentRef doc = SKDocumentCreateWithURL((CFURLRef)[pub 
identifierURL]);
+        SKDocumentRef doc = SKDocumentCreateWithURL((__bridge CFURLRef)[pub 
identifierURL]);
         if (doc) {
             
             for (NSString *field in fields) {
@@ -100,7 +100,7 @@
                 NSString *searchText = [pub searchStringForField:field];
                 SKIndexRef skIndex = (void 
*)CFDictionaryGetValue(searchIndexes, field);
                 if (searchText && skIndex)
-                    SKIndexAddDocumentWithText(skIndex, doc, 
(CFStringRef)searchText, TRUE);
+                    SKIndexAddDocumentWithText(skIndex, doc, (__bridge 
CFStringRef)searchText, TRUE);
             }
             
             CFRelease(doc);
@@ -121,7 +121,7 @@
 
 - (void)removePublications:(NSArray *)pubs {
     for (BibItem *pub in pubs) {
-        SKDocumentRef doc = SKDocumentCreateWithURL((CFURLRef)[pub 
identifierURL]);
+        SKDocumentRef doc = SKDocumentCreateWithURL((__bridge CFURLRef)[pub 
identifierURL]);
         if (doc) {
             CFDictionaryApplyFunction(searchIndexes, removeFromIndex, (void 
*)doc);
             CFRelease(doc);
@@ -138,15 +138,14 @@
     SKIndexRef skIndex;
     
     // Search Kit defaults to indexing the first 2000 terms.  This is almost 
never what we want for BibItem searching, so set it to be unlimited (zero, of 
course).
-    NSDictionary *options = [[NSDictionary alloc] 
initWithObjectsAndKeys:[NSNumber numberWithInteger:0], (id)kSKMaximumTerms, 
[NSNumber numberWithInteger:1], (id)kSKProximityIndexing, nil];
+    NSDictionary *options = @{(__bridge id)kSKMaximumTerms:@0, (__bridge 
id)kSKProximityIndexing:@1};
     for (NSString *fieldName in indexedFields) {
         indexData = CFDataCreateMutable(NULL, 0);
-        skIndex = SKIndexCreateWithMutableData(indexData, 
(CFStringRef)fieldName, kSKIndexInverted, (CFDictionaryRef)options);
-        CFDictionaryAddValue(searchIndexes, (CFStringRef)fieldName, skIndex);
+        skIndex = SKIndexCreateWithMutableData(indexData, (__bridge 
CFStringRef)fieldName, kSKIndexInverted, (__bridge CFDictionaryRef)options);
+        CFDictionaryAddValue(searchIndexes, (__bridge CFStringRef)fieldName, 
skIndex);
         CFRelease(indexData);
         CFRelease(skIndex);
     }
-    [options release];
     [self scheduleIndexFlush];
 }
 
@@ -162,10 +161,10 @@
         [indexedFields minusSet:removedFields];
         
         for (NSString *field in removedFields) {
-            SKIndexRef anIndex = 
(SKIndexRef)CFDictionaryGetValue(searchIndexes, (CFStringRef)field);
+            SKIndexRef anIndex = 
(SKIndexRef)CFDictionaryGetValue(searchIndexes, (__bridge CFStringRef)field);
             if (anIndex == NULL) continue;
             CFSetRemoveValue(indexesToFlush, anIndex);
-            CFDictionaryRemoveValue(searchIndexes, (CFStringRef)field);
+            CFDictionaryRemoveValue(searchIndexes, (__bridge 
CFStringRef)field);
         }
     }
     
@@ -172,19 +171,18 @@
     if ([addedFields count]) {
         [indexedFields unionSet:addedFields];
         
-        NSDictionary *options = [[NSDictionary alloc] 
initWithObjectsAndKeys:[NSNumber numberWithInteger:0], (id)kSKMaximumTerms, 
[NSNumber numberWithInteger:1], (id)kSKProximityIndexing, nil];
+        NSDictionary *options = @{(__bridge id)kSKMaximumTerms:@0, (__bridge 
id)kSKProximityIndexing:@1};
         CFMutableDataRef indexData;
         SKIndexRef skIndex;
         for (NSString *field in addedFields) {
-            if (CFDictionaryContainsKey(searchIndexes, (CFStringRef)field)) 
continue;
+            if (CFDictionaryContainsKey(searchIndexes, (__bridge 
CFStringRef)field)) continue;
             indexData = CFDataCreateMutable(NULL, 0);
-            skIndex = SKIndexCreateWithMutableData(indexData, 
(CFStringRef)field, kSKIndexInverted, (CFDictionaryRef)options);
-            CFDictionaryAddValue(searchIndexes, (CFStringRef)field, skIndex);
+            skIndex = SKIndexCreateWithMutableData(indexData, (__bridge 
CFStringRef)field, kSKIndexInverted, (__bridge CFDictionaryRef)options);
+            CFDictionaryAddValue(searchIndexes, (__bridge CFStringRef)field, 
skIndex);
             CFSetAddValue(indexesToFlush, skIndex);
             CFRelease(skIndex);
             CFRelease(indexData);
         }
-        [options release];
         
         [self addPublications:pubs forFields:addedFields];
     }
@@ -200,7 +198,7 @@
         SKIndexFlush(anIndex);
         CFSetRemoveValue(indexesToFlush, anIndex);
     }
-    return (SKIndexRef)[[(id)anIndex retain] autorelease];
+    return (SKIndexRef)CFAutorelease(CFRetain(anIndex));
 }
 
 @end

Modified: trunk/bibdesk/BDSKLinkedFile.m
===================================================================
--- trunk/bibdesk/BDSKLinkedFile.m      2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKLinkedFile.m      2024-01-03 10:44:11 UTC (rev 28513)
@@ -861,7 +861,7 @@
     NSURL *refURL = nil;
     
     if (fileURL) {
-        refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, 
(CFURLRef)fileURL, NULL);
+        refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, 
(__bridge CFURLRef)fileURL, NULL);
         
         if (refURL == nil) {
             // fileURL was invalid, try to update it
@@ -887,7 +887,7 @@
     if (fileURL == nil) {
         
         if (fileRefURL) {
-            aURL = (NSURL *)CFURLCreateFilePathURL(kCFAllocatorDefault, 
(CFURLRef)fileRefURL, NULL);
+            aURL = (NSURL *)CFURLCreateFilePathURL(kCFAllocatorDefault, 
(__bridge CFURLRef)fileRefURL, NULL);
             shouldUpdate = aURL != nil;
         }
         
@@ -895,7 +895,7 @@
         
         if (aURL == nil && basePath && relativePath) {
             aURL = [[NSURL alloc] initFileURLWithPath:[relativePath 
isAbsolutePath] ? relativePath : [basePath 
stringByAppendingPathComponent:relativePath] isDirectory:NO];
-            refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, 
(CFURLRef)aURL, NULL);
+            refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, 
(__bridge CFURLRef)aURL, NULL);
             shouldUpdate = refURL != nil;
         }
         
@@ -902,7 +902,7 @@
         if (refURL == nil && [alias isKindOfClass:[NSData class]]) {
             aURL = [[NSURL alloc] initByResolvingBookmarkData:alias 
options:NSURLBookmarkResolutionWithoutUI | 
NSURLBookmarkResolutionWithoutMounting relativeToURL:nil 
bookmarkDataIsStale:&shouldUpdate error:NULL];
             if (aURL)
-                refURL = (NSURL 
*)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)aURL, NULL);
+                refURL = (NSURL 
*)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (__bridge CFURLRef)aURL, 
NULL);
             shouldUpdate = shouldUpdate && aURL != nil;
         } else if (aURL == nil && [alias isKindOfClass:[BDSKAlias class]]) {
             FSRef aRef, baseRef;
@@ -910,7 +910,7 @@
             if ([alias getFSRef:&aRef baseRef:hasBaseRef ? &baseRef : NULL 
shouldUpdate:&ignored]){
                 aURL = BDSKCreateURLFromFSRef(&aRef);
                 if (aURL)
-                    refURL = (NSURL 
*)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)aURL, NULL);
+                    refURL = (NSURL 
*)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (__bridge CFURLRef)aURL, 
NULL);
             }
             shouldUpdate = aURL != nil;
         }
@@ -949,15 +949,15 @@
         if ([path isEqualToString:aPath] == NO) {
             // this can happen when auto filing to a different volume, which 
copies the file
             BOOL needsUpdate = YES;
-            NSURL *refURL = (NSURL 
*)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)[NSURL 
fileURLWithPath:aPath], NULL);
+            CFURLRef refURL = CFURLCreateFileReferenceURL(kCFAllocatorDefault, 
(__bridge CFURLRef)[NSURL fileURLWithPath:aPath], NULL);
             if (refURL) {
-                NSURL *aURL = (NSURL 
*)CFURLCreateFilePathURL(kCFAllocatorDefault, (CFURLRef)refURL, NULL);
+                NSURL *aURL = (NSURL 
*)CFURLCreateFilePathURL(kCFAllocatorDefault, refURL, NULL);
                 if ([path isEqualToString:[aURL path]]) {
-                    [refURL release];
+                    CFRelease(refURL);
                     needsUpdate = NO;
                 } else {
                     [fileRefURL release];
-                    fileRefURL = refURL;
+                    fileRefURL = (NSURL *)refURL;
                     [self setFileURL:aURL];
                 }
                 [aURL release];
@@ -1185,12 +1185,12 @@
     Handle handle = NULL;
     
     if (data != nil) {
-        len = CFDataGetLength((CFDataRef)data);
+        len = CFDataGetLength((__bridge CFDataRef)data);
         handle = NewHandle(len);
         
         if ((handle != NULL) && (len > 0)) {
             HLock(handle);
-            memmove((void *)*handle, (const void 
*)CFDataGetBytePtr((CFDataRef)data), len);
+            memmove((void *)*handle, (const void *)CFDataGetBytePtr((__bridge 
CFDataRef)data), len);
             HUnlock(handle);
         }
     }

Modified: trunk/bibdesk/BDSKNotesSearchIndex.m
===================================================================
--- trunk/bibdesk/BDSKNotesSearchIndex.m        2024-01-02 16:57:48 UTC (rev 
28512)
+++ trunk/bibdesk/BDSKNotesSearchIndex.m        2024-01-03 10:44:11 UTC (rev 
28513)
@@ -173,13 +173,12 @@
         return;
     
     CFMutableDataRef indexData = CFDataCreateMutable(NULL, 0);
-    NSDictionary *options = [[NSDictionary alloc] 
initWithObjectsAndKeys:[NSNumber numberWithInteger:0], (id)kSKMaximumTerms, 
nil];
+    NSDictionary *options = @{(id)kSKMaximumTerms:@0};
     dispatch_sync(lockQueue, ^{
         BDSKCFDESTROY(skIndex);
-        skIndex = SKIndexCreateWithMutableData(indexData, 
(CFStringRef)BDSKSkimNotesString, kSKIndexInverted, (CFDictionaryRef)options);
+        skIndex = SKIndexCreateWithMutableData(indexData, (__bridge 
CFStringRef)BDSKSkimNotesString, kSKIndexInverted, (__bridge 
CFDictionaryRef)options);
     });
     CFRelease(indexData);
-    [options release];
     
     // this will handle the index flush after adding all the pubs
     NSArray *items = [pubs valueForKey:@"searchIndexInfo"];
@@ -208,7 +207,7 @@
         SKIndexFlush(theIndex);
         atomic_store(&needsFlushing, NO);
     }
-    return (SKIndexRef)[(id)theIndex autorelease];
+    return (SKIndexRef)CFAutorelease(theIndex);
 }
 
 - (void)indexItemForIdentifierURL:(NSURL *)identifierURL fileURLs:(NSArray 
*)fileURLs removeEmpty:(BOOL)removeEmpty
@@ -216,7 +215,7 @@
     NSAutoreleasePool *pool = [NSAutoreleasePool new];
     
     @try {
-        SKDocumentRef doc = SKDocumentCreateWithURL((CFURLRef)identifierURL);
+        SKDocumentRef doc = SKDocumentCreateWithURL((__bridge 
CFURLRef)identifierURL);
         if (doc) {
             
             NSMutableString *searchText = nil;
@@ -257,7 +256,7 @@
                 BOOL didUpdate = NO;
                 if ([searchText length]) {
                     didUpdate = YES;
-                    SKIndexAddDocumentWithText(theIndex, doc, 
(CFStringRef)searchText, TRUE);
+                    SKIndexAddDocumentWithText(theIndex, doc, (__bridge 
CFStringRef)searchText, TRUE);
                 } else if (removeEmpty && kSKDocumentStateNotIndexed != 
(SKIndexGetDocumentState(theIndex, doc) % 3)) {
                     didUpdate = YES;
                     SKIndexRemoveDocument(theIndex, doc);

Modified: trunk/bibdesk/BDSKPersistentSearch.m
===================================================================
--- trunk/bibdesk/BDSKPersistentSearch.m        2024-01-02 16:57:48 UTC (rev 
28512)
+++ trunk/bibdesk/BDSKPersistentSearch.m        2024-01-03 10:44:11 UTC (rev 
28513)
@@ -86,7 +86,7 @@
 - (BOOL)hasQuery:(NSString *)queryString;
 { 
     NSParameterAssert(queryString != nil);
-    return CFDictionaryContainsKey(queries, (CFStringRef)queryString);
+    return CFDictionaryContainsKey(queries, (__bridge CFStringRef)queryString);
 }
 
 - (BOOL)addQuery:(NSString *)queryString scopes:(NSArray *)searchScopes;
@@ -95,19 +95,19 @@
     BOOL success = YES;
     MDQueryRef mdQuery = NULL;
     
-    if (CFDictionaryGetValueIfPresent(queries, (CFStringRef)queryString, 
(const void **)&mdQuery)) {
+    if (CFDictionaryGetValueIfPresent(queries, (__bridge 
CFStringRef)queryString, (const void **)&mdQuery)) {
         
         // already present in the dictionary, so just modify the scope
         if (CFEqual(nullQueryMarker, mdQuery) == FALSE)
-            MDQuerySetSearchScope(mdQuery, (CFArrayRef)searchScopes, 0);
+            MDQuerySetSearchScope(mdQuery, (__bridge CFArrayRef)searchScopes, 
0);
 
     } else {
     
-        mdQuery = MDQueryCreate(CFAllocatorGetDefault(), 
(CFStringRef)queryString, NULL, NULL);
+        mdQuery = MDQueryCreate(CFAllocatorGetDefault(), (__bridge 
CFStringRef)queryString, NULL, NULL);
     
         // mdQuery is NULL on failure
         if(mdQuery != NULL){
-            MDQuerySetSearchScope(mdQuery, (CFArrayRef)searchScopes, 0);
+            MDQuerySetSearchScope(mdQuery, (__bridge CFArrayRef)searchScopes, 
0);
         
             // create and execute an asynchronous query that will watch the 
file system for us
             // we currently ignore notifications; callers just take what they 
can get from resultsForQuery:attribute:
@@ -120,7 +120,7 @@
         } else {
             success = NO;
             // add the bogus query, so we don't keep trying; a user reported 
beachballs when creating the query with a bad spotlight cache, so we'll just 
log a message and leave out this functionality
-            CFDictionaryAddValue(queries, (const void *)queryString, 
nullQueryMarker);
+            CFDictionaryAddValue(queries, (__bridge CFStringRef)queryString, 
nullQueryMarker);
 #ifdef DEBUG
             // warning for developers, in case of using an incorrect query 
string
             NSAlert *alert = [[[NSAlert alloc] init] autorelease];
@@ -139,7 +139,7 @@
 
 - (NSArray *)resultsForQuery:(NSString *)queryString attribute:(NSString 
*)attribute;
 {
-    MDQueryRef mdQuery = (MDQueryRef)CFDictionaryGetValue(queries, 
(CFStringRef)queryString);
+    MDQueryRef mdQuery = (MDQueryRef)CFDictionaryGetValue(queries, (__bridge 
CFStringRef)queryString);
     NSMutableArray *results = nil;
     
     if(mdQuery != NULL && CFEqual(nullQueryMarker, mdQuery) == FALSE){
@@ -154,9 +154,9 @@
         
         while(idx--){
             mdItem = (MDItemRef)MDQueryGetResultAtIndex(mdQuery, idx);
-            value = MDItemCopyAttribute(mdItem, (CFStringRef)attribute);
+            value = MDItemCopyAttribute(mdItem, (__bridge 
CFStringRef)attribute);
             if(value){
-                [results addObject:(id)value];
+                [results addObject:(__bridge id)value];
                 CFRelease(value);
             }
         }

Modified: trunk/bibdesk/BDSKSearchGroup.h
===================================================================
--- trunk/bibdesk/BDSKSearchGroup.h     2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKSearchGroup.h     2024-01-03 10:44:11 UTC (rev 28513)
@@ -105,6 +105,7 @@
     id<BDSKSearchGroupServer> server;
     BOOL importFinished;
     void(^completionHandler)(NSArray *);
+    id strongSelf;
 }
 
 + (NSArray *)searchUsingSearchTerm:(NSString *)searchTerm 
serverInfo:(BDSKServerInfo *)serverInfo macroResolver:(BDSKMacroResolver 
*)macroResolver completionHandler:(void(^)(NSArray 
*publications))completionHandler;

Modified: trunk/bibdesk/BDSKSearchGroup.m
===================================================================
--- trunk/bibdesk/BDSKSearchGroup.m     2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKSearchGroup.m     2024-01-03 10:44:11 UTC (rev 28513)
@@ -515,7 +515,7 @@
     
     BOOL async = completionHandler != NULL;
     
-    [self retain];
+    strongSelf = [self retain];
     
     [server retrieveWithSearchTerm:searchTerm];
     
@@ -527,7 +527,7 @@
     
     NSArray *pubs = [publications count] > 0 ? [[publications copy] 
autorelease] : nil;
     
-    [self release];
+    BDSKDESTROY(strongSelf);
     
     return pubs;
 }
@@ -544,7 +544,7 @@
     if (completionHandler) {
         completionHandler(publications);
         BDSKDESTROY(completionHandler);
-        [self release];
+        BDSKDESTROY(strongSelf);
     }
 }
 

Modified: trunk/bibdesk/BDSKWebGroup.h
===================================================================
--- trunk/bibdesk/BDSKWebGroup.h        2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKWebGroup.h        2024-01-03 10:44:11 UTC (rev 28513)
@@ -64,6 +64,7 @@
     BDSKWebGroup *group;
     BDSKMacroResolver *macroResolver;
     void(^completionHandler)(NSArray *);
+    id strongSelf;
 }
 
 + (NSArray *)itemsFromURL:(NSURL *)aURL macroResolver:(BDSKMacroResolver 
*)macroResolver completionHandler:(void(^)(NSArray 
*publications))completionHandler;

Modified: trunk/bibdesk/BDSKWebGroup.m
===================================================================
--- trunk/bibdesk/BDSKWebGroup.m        2024-01-02 16:57:48 UTC (rev 28512)
+++ trunk/bibdesk/BDSKWebGroup.m        2024-01-03 10:44:11 UTC (rev 28513)
@@ -416,7 +416,7 @@
         completionHandler([self publications]);
         BDSKDESTROY(completionHandler);
         [[NSNotificationCenter defaultCenter] removeObserver:self];
-        [self release];
+        BDSKDESTROY(strongSelf);
     }
 }
 
@@ -424,7 +424,7 @@
     
     completionHandler = Block_copy(aCompletionHandler);
     
-    [self retain];
+    strongSelf = [self retain];
     
     [group setURL:aURL];
     
@@ -444,7 +444,7 @@
         
         NSArray *pubs = [self publications];
         
-        [self release];
+        BDSKDESTROY(strongSelf);
         
         return pubs;
         

Modified: trunk/bibdesk/BDSKWebViewModalDialogController.h
===================================================================
--- trunk/bibdesk/BDSKWebViewModalDialogController.h    2024-01-02 16:57:48 UTC 
(rev 28512)
+++ trunk/bibdesk/BDSKWebViewModalDialogController.h    2024-01-03 10:44:11 UTC 
(rev 28513)
@@ -44,6 +44,7 @@
 @interface BDSKWebViewModalDialogController : NSWindowController 
<BDSKWebViewDelegate, NSWindowDelegate> {
     BDSKWebView *webView;
     BDSKStatusBar *statusBar;
+    id strongSelf;
 }
 @property (nonatomic, readonly) BDSKWebView *webView;
 @end

Modified: trunk/bibdesk/BDSKWebViewModalDialogController.m
===================================================================
--- trunk/bibdesk/BDSKWebViewModalDialogController.m    2024-01-02 16:57:48 UTC 
(rev 28512)
+++ trunk/bibdesk/BDSKWebViewModalDialogController.m    2024-01-03 10:44:11 UTC 
(rev 28513)
@@ -70,7 +70,7 @@
 
 - (void)windowWillClose:(NSNotification *)notification {
     [NSApp stopModal];
-    [self autorelease];
+    BDSKDESTROY(strongSelf);
 }
 
 #pragma mark BDSKWebViewDelegate protocol
@@ -88,7 +88,7 @@
 }
 
 - (void)webViewRunModal:(WebView *)sender {
-    [self retain];
+    strongSelf = [self retain];
     // we can't use [NSApp runModalForWindow], because otherwise the webview 
does not download, and also it won't receive any close message from javascript
     // http://www.dejal.com/blog/2007/01/cocoa-topics-case-modal-webview
     NSModalSession session = [NSApp beginModalSessionForWindow:[self window]];

Modified: trunk/bibdesk/NSString_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSString_BDSKExtensions.m     2024-01-02 16:57:48 UTC (rev 
28512)
+++ trunk/bibdesk/NSString_BDSKExtensions.m     2024-01-03 10:44:11 UTC (rev 
28513)
@@ -185,7 +185,7 @@
 + (NSString *)stringWithFileSystemRepresentation:(const char *)cstring;
 {
     NSParameterAssert(cstring != NULL);
-    return 
[(id)CFStringCreateWithFileSystemRepresentation(CFAllocatorGetDefault(), 
cstring) autorelease];
+    return 
CFBridgingRelease(CFStringCreateWithFileSystemRepresentation(CFAllocatorGetDefault(),
 cstring));
 }
 
 + (NSString *)stringWithTriStateValue:(NSCellStateValue)triStateValue {
@@ -208,7 +208,7 @@
     // ignore failures for now
     CFStringTransform(charString, NULL, kCFStringTransformToUnicodeName, 
FALSE);
     
-    return [(id)charString autorelease];
+    return CFBridgingRelease(charString);
 } 
 
 + (NSString *)IANACharSetNameForEncoding:(NSStringEncoding)enc;
@@ -933,7 +933,7 @@
     CFMutableStringRef modifiedSelf = 
CFStringCreateMutableCopy(CFAllocatorGetDefault(), CFStringGetLength((__bridge 
CFStringRef)self), (__bridge CFStringRef)self);
     BDDeleteArticlesForSorting(modifiedSelf);
     BDDeleteTeXForSorting(modifiedSelf);
-    return [(id)modifiedSelf autorelease];
+    return CFBridgingRelease(modifiedSelf);
 }
     
 - 
(NSComparisonResult)localizedCaseInsensitiveNonTeXNonArticleCompare:(NSString 
*)otherString;
@@ -1096,7 +1096,7 @@
 
 - (NSArray *)componentsSeparatedByCharactersInSet:(NSCharacterSet *)charSet 
trimWhitespace:(BOOL)trim;
 {
-    return 
[(id)BDStringCreateComponentsSeparatedByCharacterSetTrimWhitespace(CFAllocatorGetDefault(),
 (__bridge CFStringRef)self, (__bridge CFCharacterSetRef)charSet, trim) 
autorelease];
+    return 
CFBridgingRelease(BDStringCreateComponentsSeparatedByCharacterSetTrimWhitespace(CFAllocatorGetDefault(),
 (__bridge CFStringRef)self, (__bridge CFCharacterSetRef)charSet, trim));
 }
 
 - (NSArray *)componentsSeparatedByFieldSeparators;
@@ -1110,7 +1110,7 @@
 
 - (NSArray *)componentsSeparatedByAnd;
 {
-    return 
[(id)BDStringCreateComponentsBySeparatingByAnd(CFAllocatorGetDefault(), 
(__bridge CFStringRef)self) autorelease];
+    return 
CFBridgingRelease(BDStringCreateComponentsBySeparatingByAnd(CFAllocatorGetDefault(),
 (__bridge CFStringRef)self));
 }
 
 - (NSArray *)componentsSeparatedByComma;
@@ -1120,17 +1120,17 @@
 
 - (NSString *)stringByCollapsingCharactersInSet:(NSCharacterSet *)charSet;
 {
-    return 
[(id)BDStringCreateByCollapsingCharactersInSet(CFAllocatorGetDefault(), 
(__bridge CFStringRef)self, (CFCharacterSetRef)charSet) autorelease];
+    return 
CFBridgingRelease(BDStringCreateByCollapsingCharactersInSet(CFAllocatorGetDefault(),
 (__bridge CFStringRef)self, (CFCharacterSetRef)charSet));
 }
 
 - (NSString *)stringByCollapsingAndTrimmingCharactersInSet:(NSCharacterSet 
*)charSet;
 {
-    return 
[(id)BDStringCreateByCollapsingAndTrimmingCharactersInSet(CFAllocatorGetDefault(),
 (__bridge CFStringRef)self, (__bridge CFCharacterSetRef)charSet) autorelease];
+    return 
CFBridgingRelease(BDStringCreateByCollapsingAndTrimmingCharactersInSet(CFAllocatorGetDefault(),
 (__bridge CFStringRef)self, (__bridge CFCharacterSetRef)charSet));
 }
 
 - (NSString *)stringByNormalizingSpacesAndLineBreaks;
 {
-    return 
[(id)BDStringCreateByNormalizingWhitespaceAndNewlines(CFAllocatorGetDefault(), 
(__bridge CFStringRef)self) autorelease];
+    return 
CFBridgingRelease(BDStringCreateByNormalizingWhitespaceAndNewlines(CFAllocatorGetDefault(),
 (__bridge CFStringRef)self));
 }
 
 - (NSString *)stringByAppendingEllipsis{
@@ -1244,10 +1244,10 @@
     
     NSString *toReturn = nil;
     if (words) {
-        toReturn = (NSString *)CFStringCreateByCombiningStrings(alloc, 
(__bridge CFArrayRef)words, CFSTR(" "));
+        toReturn = CFBridgingRelease(CFStringCreateByCombiningStrings(alloc, 
(__bridge CFArrayRef)words, CFSTR(" ")));
         [words release];
     }
-    return [toReturn autorelease];
+    return toReturn;
 }
 
 - (NSString *)stringByTrimmingFromLastPunctuation{
@@ -1404,10 +1404,10 @@
         }
     }
     
-    NSString *resultString = (NSString 
*)CFStringCreateWithBytes(kCFAllocatorDefault, dest, j, kCFStringEncodingASCII, 
FALSE);
+    NSString *resultString = 
CFBridgingRelease(CFStringCreateWithBytes(kCFAllocatorDefault, dest, j, 
kCFStringEncodingASCII, FALSE));
     NSZoneFree(NULL, dest);
     
-    return [resultString autorelease];
+    return resultString;
 }
 
 - (NSData *)sha1Signature {
@@ -1492,7 +1492,7 @@
         idx++;
     }
     
-    return [(id)theString autorelease] ?: self;
+    return CFBridgingRelease(theString) ?: self;
 }
 
 #pragma mark Paths
@@ -1597,7 +1597,7 @@
 
 - (NSString *)stringByEscapingBasicXMLEntitiesUsingUTF8;
 {
-    return [(NSString 
*)BDXMLCreateStringWithEntityReferencesInCFEncoding((__bridge CFStringRef)self, 
kCFStringEncodingUTF8) autorelease];
+    return 
CFBridgingRelease(BDXMLCreateStringWithEntityReferencesInCFEncoding((__bridge 
CFStringRef)self, kCFStringEncodingUTF8));
 }
     
 #define APPEND_PREVIOUS() \

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