Index: Source/NSPrintOperation.m
===================================================================
--- Source/NSPrintOperation.m	(Revision 24757)
+++ Source/NSPrintOperation.m	(Arbeitskopie)
@@ -86,7 +86,7 @@
 - (BOOL) _runOperation;
 - (void) _setupPrintInfo;
 - (void)_printOperationDidRun:(NSPrintOperation *)printOperation 
-		                  success:(BOOL)success  
+		               returnCode:(int)returnCode
 		              contextInfo:(void *)contextInfo;
 - (void) _printPaginateWithInfo: (page_info_t *)info 
                      knowsRange: (BOOL)knowsRange;
@@ -532,9 +532,9 @@
   [panel updateFromPrintInfo];
   [panel beginSheetWithPrintInfo: _print_info 
 	          modalForWindow: docWindow 
-			delegate: delegate 
+			delegate: self 
 		  didEndSelector: 
-		          @selector(_printOperationDidRun:sucess:contextInfo:)
+		          @selector(_printOperationDidRun:returnCode:contextInfo:)
 		      contextInfo: contextInfo];
   [panel setAccessoryView: nil];
 }
@@ -683,29 +683,29 @@
 }
 
 - (void)_printOperationDidRun:(NSPrintOperation *)printOperation 
-		      success:(BOOL)success  
+		   returnCode:(int)returnCode  
 		  contextInfo:(void *)contextInfo
 {
   id delegate;
-  SEL *didRunSelector;
+  SEL didRunSelector;
+  BOOL success = NO;
   NSMutableDictionary *dict;
   void (*didRun)(id, SEL, BOOL, id);
 
-  if (success == YES)
+  if (returnCode == NSOKButton)
     {
       NSPrintPanel *panel = [self printPanel];
       [panel finalWritePrintInfo];
-      success = NO;
       if ([self _runOperation])
 	success = [self deliverResult];
     }
   [self cleanUpOperation];
   dict = [_print_info dictionary];
-  didRunSelector = [[dict objectForKey: @"GSModalRunSelector"] pointerValue];
+  [[dict objectForKey: @"GSModalRunSelector"] getValue:&didRunSelector];
   delegate = [dict objectForKey: @"GSModalRunDelegate"];
   didRun = (void (*)(id, SEL, BOOL, id))[delegate methodForSelector: 
-						    *didRunSelector];
-  didRun (delegate, *didRunSelector, success, contextInfo);
+						     didRunSelector];
+  didRun (delegate, didRunSelector, success, contextInfo);
 }
 
 
Index: Source/NSPrintPanel.m
===================================================================
--- Source/NSPrintPanel.m	(Revision 24757)
+++ Source/NSPrintPanel.m	(Arbeitskopie)
@@ -219,10 +219,10 @@
 - (int)runModal
 {
   _picked = NSOKButton;
-  [NSApp runModalForWindow: self];
+  int ret = [NSApp runModalForWindow: self];
   [_optionPanel orderOut: self];
   /* Don't order ourselves out, let the NSPrintOperation do that */
-  return (_picked == NSCancelButton) ? NSCancelButton :  NSOKButton;
+  return ret;
 }
 
 - (void) beginSheetWithPrintInfo: (NSPrintInfo *)printInfo 
@@ -308,7 +308,7 @@
     {
       NSLog(@"Print panel buttonAction: from unknown sender - x%p\n", sender);
     }
-  [NSApp stopModalWithCode: _picked];
+  [NSApp stopModalWithCode: (_picked == NSCancelButton) ? NSCancelButton :  NSOKButton];
 }
 
 - (void) _pickedPage: (id)sender
Index: Source/NSDocument.m
===================================================================
--- Source/NSDocument.m	(Revision 24757)
+++ Source/NSDocument.m	(Arbeitskopie)
@@ -196,6 +196,7 @@
   RELEASE(_window_controllers);
   RELEASE(_window);
   RELEASE(_print_info);
+  RELEASE(_printOp_delegate);
   RELEASE(_save_panel_accessory);
   RELEASE(_spa_button);
   RELEASE(_save_type);
@@ -1253,12 +1254,30 @@
                 didRunSelector: (SEL)sel
                    contextInfo: (void *)context
 {
+  ASSIGN(_printOp_delegate, delegate);
+  _printOp_didRunSelector = sel;
   [op runOperationModalForWindow: [self windowForSheet]
-      delegate: delegate 
-      didRunSelector: sel
+      delegate: self 
+      didRunSelector: @selector(_runModalPrintOperationDidSucceed:contextInfo:)
       contextInfo: context];
 }
 
+- (void)_runModalPrintOperationDidSucceed: (BOOL)success
+			      contextInfo: (void *)context
+{
+  id delegate = _printOp_delegate;
+  SEL didRunSelector = _printOp_didRunSelector;
+  void (*didRun)(id, SEL, NSDocument *, BOOL, id);
+
+  if (delegate && [delegate respondsToSelector:didRunSelector])
+    {
+      didRun = (void (*)(id, SEL, NSDocument *, BOOL, id))
+	  [delegate methodForSelector:didRunSelector];
+      didRun(delegate, didRunSelector, self, success, context);
+    }
+  DESTROY(_printOp_delegate);
+}
+
 - (BOOL)validateMenuItem: (NSMenuItem *)anItem
 {
   BOOL result = YES;
Index: Headers/AppKit/NSDocument.h
===================================================================
--- Headers/AppKit/NSDocument.h	(Revision 24757)
+++ Headers/AppKit/NSDocument.h	(Arbeitskopie)
@@ -96,6 +96,8 @@
     NSString		*_last_component_file_name; // file name last component
     NSURL		*_autosaved_file_url;	// Autosave location as URL
     NSPrintInfo 	*_print_info;		// print info record
+    id			_printOp_delegate;	// delegate and selector called
+    SEL			_printOp_didRunSelector;//   after modal print operation
     NSView 		*_save_panel_accessory;	// outlet for the accessory save-panel view
     NSPopUpButton	*_spa_button;     	// outlet for "the File Format:" button in the save panel.
     NSString            *_save_type;             // the currently selected extension.
