Revision: 28606
          http://sourceforge.net/p/bibdesk/svn/28606
Author:   hofman
Date:     2024-01-15 00:05:58 +0000 (Mon, 15 Jan 2024)
Log Message:
-----------
call callback directly instead of using NSInvocation

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.m
    trunk/bibdesk/BDSKFilterController.m

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2024-01-14 23:51:01 UTC (rev 28605)
+++ trunk/bibdesk/BDSKEditor.m  2024-01-15 00:05:58 UTC (rev 28606)
@@ -400,12 +400,11 @@
     BOOL didCommit = [self commitEditingAndReturnError:NULL];
     if (delegate && didCommitSelector) {
         // - (void)editor:(id)editor didCommit:(BOOL)didCommit 
contextInfo:(void *)contextInfo
-        NSInvocation *invocation = [NSInvocation invocationWithTarget:delegate 
selector:didCommitSelector];
-        __unsafe_unretained id unretainedSelf = self;
-        [invocation setArgument:&unretainedSelf atIndex:2];
-        [invocation setArgument:&didCommit atIndex:3];
-        [invocation setArgument:&contextInfo atIndex:4];
-        dispatch_async(dispatch_get_main_queue(), ^{ [invocation invoke]; });
+        dispatch_async(dispatch_get_main_queue(), ^{
+            void (*didCommitImp)(id, SEL, id, BOOL, void *) = (void (*)(id, 
SEL, id, BOOL, void *))[delegate methodForSelector:didCommitSelector];
+            if (didCommitImp)
+                didCommitImp(delegate, didCommitSelector, self, didCommit, 
contextInfo);
+        });
     }
 }
 

Modified: trunk/bibdesk/BDSKFilterController.m
===================================================================
--- trunk/bibdesk/BDSKFilterController.m        2024-01-14 23:51:01 UTC (rev 
28605)
+++ trunk/bibdesk/BDSKFilterController.m        2024-01-15 00:05:58 UTC (rev 
28606)
@@ -278,12 +278,11 @@
     BOOL didCommit = [self commitEditing];
     if (delegate && didCommitSelector) {
         // - (void)editor:(id)editor didCommit:(BOOL)didCommit 
contextInfo:(void *)contextInfo
-        NSInvocation *invocation = [NSInvocation invocationWithTarget:delegate 
selector:didCommitSelector];
-        __unsafe_unretained id unretainedSelf = self;
-        [invocation setArgument:&unretainedSelf atIndex:2];
-        [invocation setArgument:&didCommit atIndex:3];
-        [invocation setArgument:&contextInfo atIndex:4];
-        dispatch_async(dispatch_get_main_queue(), ^{ [invocation invoke]; });
+        dispatch_async(dispatch_get_main_queue(), ^{
+            void (*didCommitImp)(id, SEL, id, BOOL, void *) = (void (*)(id, 
SEL, id, BOOL, void *))[delegate methodForSelector:didCommitSelector];
+            if (didCommitImp)
+                didCommitImp(delegate, didCommitSelector, self, didCommit, 
contextInfo);
+        });
     }
 }
 

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