Revision: 28556
          http://sourceforge.net/p/bibdesk/svn/28556
Author:   hofman
Date:     2024-01-05 20:01:54 +0000 (Fri, 05 Jan 2024)
Log Message:
-----------
copy SKIndexRef in to avoid CFAutoRelease

Modified Paths:
--------------
    trunk/bibdesk/BDSKItemSearchIndexes.h
    trunk/bibdesk/BDSKItemSearchIndexes.m
    trunk/bibdesk/BDSKNotesSearchIndex.h
    trunk/bibdesk/BDSKNotesSearchIndex.m
    trunk/bibdesk/BDSKPublicationsArray.h
    trunk/bibdesk/BDSKPublicationsArray.m
    trunk/bibdesk/BibDocument_Search.m

Modified: trunk/bibdesk/BDSKItemSearchIndexes.h
===================================================================
--- trunk/bibdesk/BDSKItemSearchIndexes.h       2024-01-05 19:43:07 UTC (rev 
28555)
+++ trunk/bibdesk/BDSKItemSearchIndexes.h       2024-01-05 20:01:54 UTC (rev 
28556)
@@ -47,7 +47,7 @@
 - (void)removePublications:(NSArray *)pubs;
 - (void)addPublications:(NSArray *)pubs;
 
-- (SKIndexRef)indexForField:(NSString *)field;
+- (SKIndexRef)copyIndexForField:(NSString *)field;
 
 - (void)reset;
 

Modified: trunk/bibdesk/BDSKItemSearchIndexes.m
===================================================================
--- trunk/bibdesk/BDSKItemSearchIndexes.m       2024-01-05 19:43:07 UTC (rev 
28555)
+++ trunk/bibdesk/BDSKItemSearchIndexes.m       2024-01-05 20:01:54 UTC (rev 
28556)
@@ -191,7 +191,7 @@
     [removedFields release];
 }
 
-- (SKIndexRef)indexForField:(NSString *)field {
+- (SKIndexRef)copyIndexForField:(NSString *)field {
     NSParameterAssert(nil != field);
     SKIndexRef anIndex = (SKIndexRef)CFDictionaryGetValue(searchIndexes, 
(CFStringRef)field);
     if (CFSetContainsValue(indexesToFlush, anIndex)) {
@@ -198,7 +198,7 @@
         SKIndexFlush(anIndex);
         CFSetRemoveValue(indexesToFlush, anIndex);
     }
-    return (SKIndexRef)CFAutorelease(CFRetain(anIndex));
+    return (SKIndexRef)CFRetain(anIndex);
 }
 
 @end

Modified: trunk/bibdesk/BDSKNotesSearchIndex.h
===================================================================
--- trunk/bibdesk/BDSKNotesSearchIndex.h        2024-01-05 19:43:07 UTC (rev 
28555)
+++ trunk/bibdesk/BDSKNotesSearchIndex.h        2024-01-05 20:01:54 UTC (rev 
28556)
@@ -64,7 +64,7 @@
 - (void)resetWithPublications:(NSArray *)pubs;
 
 // Warning:  it is /not/ safe to write to this SKIndexRef directly; use it 
only for reading.
-@property (nonatomic, readonly) SKIndexRef index;
+@property (nonatomic, readonly) SKIndexRef copyIndex;
 
 // call when closing the document window; kills the search and prevents 
further callbacks
 - (void)terminate;

Modified: trunk/bibdesk/BDSKNotesSearchIndex.m
===================================================================
--- trunk/bibdesk/BDSKNotesSearchIndex.m        2024-01-05 19:43:07 UTC (rev 
28555)
+++ trunk/bibdesk/BDSKNotesSearchIndex.m        2024-01-05 20:01:54 UTC (rev 
28556)
@@ -57,7 +57,7 @@
 @implementation BDSKNotesSearchIndex
 
 @synthesize delegate;
-@dynamic index;
+@dynamic copyIndex;
 
 - (id)initForOwner:(id <BDSKOwner>)owner
 {
@@ -195,7 +195,7 @@
 }
 
 
-- (SKIndexRef)index
+- (SKIndexRef)copyIndex
 {
     if (terminated)
         return NULL;
@@ -208,7 +208,7 @@
         SKIndexFlush(theIndex);
         atomic_store(&needsFlushing, NO);
     }
-    return (SKIndexRef)CFAutorelease(theIndex);
+    return theIndex;
 }
 
 - (void)indexItemForIdentifierURL:(NSURL *)identifierURL fileURLs:(NSArray 
*)fileURLs removeEmpty:(BOOL)removeEmpty

Modified: trunk/bibdesk/BDSKPublicationsArray.h
===================================================================
--- trunk/bibdesk/BDSKPublicationsArray.h       2024-01-05 19:43:07 UTC (rev 
28555)
+++ trunk/bibdesk/BDSKPublicationsArray.h       2024-01-05 20:01:54 UTC (rev 
28556)
@@ -61,7 +61,7 @@
 - (BibItem *)itemForIdentifierURL:(NSURL *)aURL;
 - (NSArray *)itemsForIdentifierURLs:(NSArray *)anArray;
 
-- (SKIndexRef)indexForField:(NSString *)field;
+- (SKIndexRef)copyIndexForField:(NSString *)field;
 
 - (void)reindexPublication:(BibItem *)pub;
 

Modified: trunk/bibdesk/BDSKPublicationsArray.m
===================================================================
--- trunk/bibdesk/BDSKPublicationsArray.m       2024-01-05 19:43:07 UTC (rev 
28555)
+++ trunk/bibdesk/BDSKPublicationsArray.m       2024-01-05 20:01:54 UTC (rev 
28556)
@@ -306,8 +306,8 @@
 
 #pragma mark Search indexes
 
-- (SKIndexRef)indexForField:(NSString *)field {
-    return [searchIndexes indexForField:field];
+- (SKIndexRef)copyIndexForField:(NSString *)field {
+    return [searchIndexes copyIndexForField:field];
 }
 
 - (void)reindexPublication:(BibItem *)pub {

Modified: trunk/bibdesk/BibDocument_Search.m
===================================================================
--- trunk/bibdesk/BibDocument_Search.m  2024-01-05 19:43:07 UTC (rev 28555)
+++ trunk/bibdesk/BibDocument_Search.m  2024-01-05 20:01:54 UTC (rev 28556)
@@ -195,16 +195,17 @@
             
             // we need the correct search index
             if ([field isEqualToString:BDSKSkimNotesString])
-                skIndex = [notesSearchIndex index];
+                skIndex = [notesSearchIndex copyIndex];
             else if ([self hasGroupTypeSelected:BDSKExternalGroupType])
-                skIndex = [[[[self selectedGroups] firstObject] publications] 
indexForField:field];
+                skIndex = [[[[self selectedGroups] firstObject] publications] 
copyIndexForField:field];
             else
-                skIndex = [publications indexForField:field];
+                skIndex = [publications copyIndexForField:field];
             
             if (skIndex) {
                 if (documentSearch == nil)
                     documentSearch = [[BDSKDocumentSearch alloc] 
initWithDelegate:self];
                 [documentSearch 
searchForString:BDSKSearchKitExpressionWithString(searchString) index:skIndex 
selectedPublications:pubsToSelect scrollPositionAsPercentage:[tableView 
scrollPositionAsPercentage]];
+                CFRelease(skIndex);
             } else {
                 // the index can be nil when the external group has no 
publications
                 [shownPublications removeAllObjects];
@@ -486,7 +487,9 @@
 
 - (void)notesSearchIndexDidUpdate:(BDSKNotesSearchIndex *)searchIndex {
     if ([self displaysControlView:BDSKControlViewSearch] && [[searchButtonBar 
selectedIdentifier] isEqualToString:BDSKSkimNotesString]) {
-        [documentSearch 
searchForString:BDSKSearchKitExpressionWithString([searchField stringValue]) 
index:[notesSearchIndex index] selectedPublications:[self selectedPublications] 
scrollPositionAsPercentage:[tableView scrollPositionAsPercentage]];
+        SKIndexRef skIndex = [notesSearchIndex copyIndex];
+        [documentSearch 
searchForString:BDSKSearchKitExpressionWithString([searchField stringValue]) 
index:skIndex selectedPublications:[self selectedPublications] 
scrollPositionAsPercentage:[tableView scrollPositionAsPercentage]];
+        CFRelease(skIndex);
     }
 }
 

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