Revision: 6998
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6998&view=rev
Author:   hofman
Date:     2010-12-21 13:32:35 +0000 (Tue, 21 Dec 2010)

Log Message:
-----------
call print callback with a zero delay, so it is deferred until after printing 
is finished

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

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2010-12-21 13:07:42 UTC (rev 6997)
+++ trunk/SKMainDocument.m      2010-12-21 13:32:35 UTC (rev 6998)
@@ -877,11 +877,12 @@
 
 - (void)handleWindowDidEndPrintSheetNotification:(NSNotification 
*)notification {
     // This is only called to delay a print callback
-    [[NSNotificationCenter defaultCenter] removeObserver:self 
name:NSWindowDidEndSheetNotification object:[notification object]];
+    if (notification)
+        [[NSNotificationCenter defaultCenter] removeObserver:self 
name:NSWindowDidEndSheetNotification object:[notification object]];
     if (printCallback) {
         BOOL didPrint = YES;
         [printCallback setArgument:&didPrint atIndex:3];
-        [printCallback invoke];
+        [printCallback performSelector:@selector(invoke) withObject:nil 
afterDelay:0.0];
         SKDESTROY(printCallback);
     }
 }
@@ -900,17 +901,14 @@
     [[self pdfView] printWithInfo:printInfo autoRotate:autoRotate 
pageScaling:pageScaling];
     
     if (delegate && didPrintSelector) {
-        NSInvocation *invocation = [NSInvocation invocationWithTarget:delegate 
selector:didPrintSelector];
-        [invocation setArgument:&self atIndex:2];
-        [invocation setArgument:&contextInfo atIndex:4];
-        if (showPrintPanel && [[[self mainWindowController] window] 
attachedSheet]) {
-            printCallback = [invocation retain];
-            [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleWindowDidEndPrintSheetNotification:) 
name:NSWindowDidEndSheetNotification object:[self windowForSheet]];
-        } else {
-            BOOL didPrint = YES;
-            [invocation setArgument:&didPrint atIndex:3];
-            [invocation invoke];
-        }
+        printCallback = [[NSInvocation invocationWithTarget:delegate 
selector:didPrintSelector] retain];
+        [printCallback setArgument:&self atIndex:2];
+        [printCallback setArgument:&contextInfo atIndex:4];
+        NSWindow *printWindow = [[self pdfView] window];
+        if (showPrintPanel && [printWindow attachedSheet])
+            [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleWindowDidEndPrintSheetNotification:) 
name:NSWindowDidEndSheetNotification object:printWindow];
+        else
+            [self handleWindowDidEndPrintSheetNotification:nil];
     }
 }
 


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

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to