Revision: 29284
          http://sourceforge.net/p/bibdesk/svn/29284
Author:   hofman
Date:     2025-07-17 17:47:26 +0000 (Thu, 17 Jul 2025)
Log Message:
-----------
present commit error in sheet from async commit method

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

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2025-07-17 17:21:21 UTC (rev 29283)
+++ trunk/bibdesk/BDSKEditor.m  2025-07-17 17:47:26 UTC (rev 29284)
@@ -400,10 +400,32 @@
     [self setEditing:NO];
 }
 
+- (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void 
*)contextInfo {
+    NSInvocation *invocation = (NSInvocation *)CFBridgingRelease(contextInfo);
+    if (invocation) {
+        [invocation setArgument:&didRecover atIndex:3];
+        [invocation invoke];
+    }
+}
 - (void)commitEditingWithDelegate:(id)delegate 
didCommitSelector:(SEL)didCommitSelector contextInfo:(void *)contextInfo
 {
-    BOOL didCommit = [self commitEditingAndReturnError:NULL];
-    if (delegate && didCommitSelector) {
+    NSError *error = nil;
+    BOOL didCommit = [self commitEditingAndReturnError:&error];
+    if (didCommit == NO) {
+        id aDelegate = nil;
+        SEL aSelector = NULL;
+        void *aContextInfo = NULL;
+        if (delegate && didCommitSelector) {
+            NSInvocation *invocation = [NSInvocation 
invocationWithTarget:delegate selector:didCommitSelector];
+            __unsafe_unretained id editor = self;
+            [invocation setArgument:&editor atIndex:2];
+            [invocation setArgument:&contextInfo atIndex:4];
+            aDelegate = self;
+            aSelector = @selector(didPresentErrorWithRecovery:contextInfo:);
+            aContextInfo = (void *)CFBridgingRetain(invocation);
+        }
+        [self presentError:error modalForWindow:[self window] 
delegate:aDelegate didPresentSelector:aSelector contextInfo:aContextInfo];
+    } else if (delegate && didCommitSelector) {
         // - (void)editor:(id)editor didCommit:(BOOL)didCommit 
contextInfo:(void *)contextInfo
         dispatch_async(dispatch_get_main_queue(), ^{
             void (*didCommitImp)(id, SEL, id, BOOL, void *) = (void (*)(id, 
SEL, id, BOOL, void *))[delegate methodForSelector:didCommitSelector];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to