Revision: 29324
          http://sourceforge.net/p/bibdesk/svn/29324
Author:   hofman
Date:     2025-07-22 14:43:58 +0000 (Tue, 22 Jul 2025)
Log Message:
-----------
handle array of crossreffed items

Modified Paths:
--------------
    trunk/bibdesk/BDSKPublicationsArray.h
    trunk/bibdesk/BDSKPublicationsArray.m
    trunk/bibdesk/BibDocument_UI.m

Modified: trunk/bibdesk/BDSKPublicationsArray.h
===================================================================
--- trunk/bibdesk/BDSKPublicationsArray.h       2025-07-22 14:24:08 UTC (rev 
29323)
+++ trunk/bibdesk/BDSKPublicationsArray.h       2025-07-22 14:43:58 UTC (rev 
29324)
@@ -68,7 +68,7 @@
 
 - (nullable SKIndexRef)copyIndexForField:(NSString *)field;
 
-- (void)reindexPublication:(BibItem *)pub;
+- (void)reindexPublications:(NSArray *)items;
 
 @end
 

Modified: trunk/bibdesk/BDSKPublicationsArray.m
===================================================================
--- trunk/bibdesk/BDSKPublicationsArray.m       2025-07-22 14:24:08 UTC (rev 
29323)
+++ trunk/bibdesk/BDSKPublicationsArray.m       2025-07-22 14:43:58 UTC (rev 
29324)
@@ -318,8 +318,8 @@
     return [searchIndexes copyIndexForField:field];
 }
 
-- (void)reindexPublication:(BibItem *)pub {
-    [searchIndexes addPublications:@[pub]];
+- (void)reindexPublications:(NSArray *)items {
+    [searchIndexes addPublications:items];
 }
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change context:(void *)context {

Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m      2025-07-22 14:24:08 UTC (rev 29323)
+++ trunk/bibdesk/BibDocument_UI.m      2025-07-22 14:43:58 UTC (rev 29324)
@@ -1439,7 +1439,7 @@
     // All Fields contains all dependencies of any search field
     BOOL shouldReindex = isEdit == NO && 
searchKeyDependsOnKey(BDSKAllFieldsString, changedKey);
     if (shouldReindex)
-        [publications reindexPublication:pub];
+        [publications reindexPublications:@[pub]];
     
     if ([changedKey isEqualToString:BDSKLocalFileString]) {
         NSDictionary *notifInfo = @{BDSKDocumentPublicationsKey:@[pub]};
@@ -1452,11 +1452,9 @@
         NSArray *crossreffedItems = [publications allItemsForCrossref:key];
         if ([crossreffedItems count]) {
             // invalidate groups that depend on inherited values
-            for (BibItem *aPub in crossreffedItems) {
-                [aPub resetGroups];
-                if (shouldReindex)
-                    [publications reindexPublication:aPub];
-            }
+            [crossreffedItems 
makeObjectsPerformSelector:@selector(resetGroups)];
+            if (shouldReindex)
+                [publications reindexPublications:crossreffedItems];
             [changedPublications addObject:crossreffedItems];
             // all inherited fields could change when parent is created, needs 
full UI update
             if ([changedKey isEqualToString:BDSKCiteKeyString])
@@ -1464,20 +1462,16 @@
         }
         if (oldKey) {
             // change the crossrefs if we change the parent cite key
-            crossreffedItems = [[publications allItemsForCrossref:oldKey] 
copy];
+            crossreffedItems = [publications allItemsForCrossref:oldKey];
             if ([crossreffedItems count]) {
-                for (BibItem *aPub in crossreffedItems)
+                for (BibItem *aPub in [crossreffedItems copy])
                     [aPub setField:BDSKCrossrefString toValue:key];
             }
             
             // access type manager outside the enumerator, since it's 
@synchronized...
-            NSCharacterSet *invalidSet = nil;
-            NSSet *citeFields = nil;
-            if (oldKey) {
-                BDSKTypeManager *typeManager = [BDSKTypeManager sharedManager];
-                invalidSet = [typeManager 
invalidCharactersForField:BDSKCiteKeyString];
-                citeFields = [typeManager citationFieldsSet];
-            }
+            BDSKTypeManager *typeManager = [BDSKTypeManager sharedManager];
+            NSCharacterSet *invalidSet = [typeManager 
invalidCharactersForField:BDSKCiteKeyString];
+            NSSet *citeFields = [typeManager citationFieldsSet];
             // change the key in the citation fields
             for (BibItem *aPub in publications) {
                 for (NSString *field in citeFields) {

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