Revision: 22614
          http://sourceforge.net/p/bibdesk/svn/22614
Author:   hofman
Date:     2018-09-15 21:01:02 +0000 (Sat, 15 Sep 2018)
Log Message:
-----------
Only rebuild people of changed field, invalidated other people may no reload

Modified Paths:
--------------
    trunk/bibdesk/BibItem.m

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2018-09-15 13:57:02 UTC (rev 22613)
+++ trunk/bibdesk/BibItem.m     2018-09-15 21:01:02 UTC (rev 22614)
@@ -645,22 +645,28 @@
 #pragma mark -
 #pragma mark Generic person handling code
 
+- (void)rebuildPeopleForField:(NSString *)field{
+    if (people != nil) {
+        // invalidate and remove old people if necessary
+        [[people objectForKey:field] setValue:nil forKey:@"publication"];
+        // get the string representation from pubFields
+        NSString *personStr = [pubFields objectForKey:field];
+        // parse into an array of BibAuthor objects
+        NSArray *tmpPeople = [BDSKBibTeXParser 
authorsFromBibtexString:personStr withPublication:self forField:field];
+        if ([tmpPeople count])
+            [people setObject:tmpPeople forKey:field];
+        else
+            [people removeObjectForKey:field];
+    }
+}
+
+
 - (void)rebuildPeopleIfNeeded{
-    
     if (people == nil) {
         people = [[NSMutableDictionary alloc] initWithCapacity:2];
-        
-        for (NSString *personType in [[BDSKTypeManager sharedManager] 
personFieldsSet]) {
-            // get the string representation from pubFields
-            NSString *personStr = [pubFields objectForKey:personType];
-            
-            // parse into an array of BibAuthor objects
-            NSArray *tmpPeople = [BDSKBibTeXParser 
authorsFromBibtexString:personStr withPublication:self forField:personType];
-            if ([tmpPeople count])
-                [people setObject:tmpPeople forKey:personType];
-        }
-        
-    }    
+        for (NSString *personType in [[BDSKTypeManager sharedManager] 
personFieldsSet])
+            [self rebuildPeopleForField:personType];
+    }
 }
 
 // this returns a set so it's clear that the objects are unordered
@@ -3716,13 +3722,12 @@
     BOOL allFieldsChanged = [BDSKAllFieldsString isEqualToString:key];
     
     // invalidate people (authors, editors, etc.) if necessary
-    if (allFieldsChanged || [key isPersonField]) {
-        if (allFieldsChanged == NO)
-            for (NSString *field in people)
-                [groups removeObjectForKey:field];
+    if (allFieldsChanged) {
         [[people allValues] setValue:nil forKey:@"publication"];
         [people release];
         people = nil;
+    } else if ([key isPersonField]) {
+        [self rebuildPeopleForField:key];
     }
        
     // see if we need to use the crossref workaround (BibTeX bug)

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