Revision: 14735
          http://sourceforge.net/p/skim-app/code/14735
Author:   hofman
Date:     2024-11-21 15:35:47 +0000 (Thu, 21 Nov 2024)
Log Message:
-----------
set block variable to NSNotFound to indicate we did not decide whether to be 
successfull

Modified Paths:
--------------
    trunk/SKApplicationController.m

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2024-11-21 10:05:34 UTC (rev 14734)
+++ trunk/SKApplicationController.m     2024-11-21 15:35:47 UTC (rev 14735)
@@ -309,7 +309,7 @@
     NSURL *fileURL = [NSURL fileURLWithPath:[fileNames firstObject]];
     NSArray *nextFileNames = count > 1 ? [fileNames 
subarrayWithRange:NSMakeRange(1, count - 1)] : nil;
     // keep track to see whether we finished before this method returns
-    __block NSApplicationPrintReply reply = NSPrintingReplyLater;
+    __block NSApplicationPrintReply reply = NSNotFound;
     
     [[NSDocumentController sharedDocumentController] 
openDocumentWithContentsOfURL:fileURL display:NO completionHandler:^(NSDocument 
*document, BOOL documentWasAlreadyOpen, NSError *error){
         if (document) {
@@ -323,26 +323,23 @@
                     aReply = [self application:NSApp printFiles:nextFileNames 
withSettings:printSettings showPrintPanels:showPrintPanels];
                 else
                     aReply = NSPrintingSuccess;
-                if (reply == NSPrintingReplyLater)
+                if (reply == NSNotFound)
                     reply = aReply;
-                else if (aReply != NSPrintingReplyLater)
+                else if (reply == NSPrintingReplyLater && aReply != 
NSPrintingReplyLater)
                     [NSApp replyToOpenOrPrint:aReply == NSPrintingSuccess ? 
NSApplicationDelegateReplySuccess : NSApplicationDelegateReplyFailure];
             };
             [document printDocumentWithSettings:printSettings 
showPrintPanel:showPrintPanels delegate:self 
didPrintSelector:@selector(document:didPrint:contextInfo:) contextInfo:(void 
*)CFBridgingRetain(block)];
         } else {
-            if (reply != NSPrintingReplyLater)
+            if (reply == NSPrintingReplyLater)
                 [NSApp replyToOpenOrPrint:NSApplicationDelegateReplyFailure];
             reply = NSPrintingFailure;
         }
     }];
     
-    if (reply == NSPrintingReplyLater) {
-        // set the block variable to note to the finishing block it needs to 
reply
-        reply = NSPrintingCancelled;
-        return NSPrintingReplyLater;
-    } else {
-        return reply;
-    }
+    // setting this tells the async block that we returned
+    if (reply == NSNotFound)
+        reply = NSPrintingReplyLater;
+    return reply;
 }
 
 - (void)applicationStartsTerminating:(NSNotification *)aNotification {

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to