Revision: 28324
          http://sourceforge.net/p/bibdesk/svn/28324
Author:   hofman
Date:     2023-07-17 14:54:03 +0000 (Mon, 17 Jul 2023)
Log Message:
-----------
completion handler as variable to avoid implementing code twice

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

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2023-07-17 14:16:45 UTC (rev 28323)
+++ trunk/bibdesk/BibDocument.m 2023-07-17 14:54:03 UTC (rev 28324)
@@ -1161,22 +1161,20 @@
         if (completionHandler)
             completionHandler(errorOrNil);
         
-        if (errorOrNil == nil && BDSKIsSaveOrSaveAsOperation(saveOperation)) {
-            // rebuild metadata cache for this document whenever we save
-            [[BDSKMetadataCacheQueue sharedQueue] 
saveMetadataCacheForPublications:[self publications] documentURL:absoluteURL 
isUpdate:BDSKIsSaveOperation(saveOperation)];
-            [self runScriptHookWithName:BDSKScriptHookNameSaveDocument 
forPublications:nil completionHandler:^(BOOL cancelled){
-                docFlags.isSaving = NO;
-                if (shouldCloseInvocation) {
-                    [shouldCloseInvocation invoke];
-                    BDSKDESTROY(shouldCloseInvocation);
-                }
-            }];
-        } else {
+        void (^saveCompletionHandler)(BOOL) = ^(BOOL cancelled){
             docFlags.isSaving = NO;
             if (shouldCloseInvocation) {
                 [shouldCloseInvocation invoke];
                 BDSKDESTROY(shouldCloseInvocation);
             }
+        };
+        
+        if (errorOrNil == nil && BDSKIsSaveOrSaveAsOperation(saveOperation)) {
+            // rebuild metadata cache for this document whenever we save
+            [[BDSKMetadataCacheQueue sharedQueue] 
saveMetadataCacheForPublications:[self publications] documentURL:absoluteURL 
isUpdate:BDSKIsSaveOperation(saveOperation)];
+            [self runScriptHookWithName:BDSKScriptHookNameSaveDocument 
forPublications:nil completionHandler:saveCompletionHandler];
+        } else {
+            saveCompletionHandler(NO);
         }
     }];
 }

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