Printing with Snow Leopard
Printing with Snow Leopard
- Subject: Printing with Snow Leopard
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Fri, 11 Sep 2009 12:54:36 +0700
An app which ran without problems on Leopard likes to crash on Snow
Leopard (10.6.1) (both in i386 and x86_64).
How to crash: print several times; might crash the first time, might
crash the seventh time, but crash it will.
The backtrace and the location of the crash varies wildly. In almost
always it is some NSFont method.
The backtrace below is an exception. But still related to layout stuff.
I have a very strong feeling, that something (my code? Apple's
printing code?) corrupts some memory which then results in random
errors.
Or maybe not: just ran it a dozen times with GuardMalloc and it
refused to crash. And GuardMalloc did not report any problems.
So maybe it is some timing problem with multiple threads?
I tried it more than a dozen times with: setCanSpawnSeparateThread: NO
and it did not crash.
Are there any known problems with printing using
setCanSpawnSeparateThread: YES?
====== the code ========
- (IBAction)printIt: sender ;
{
(void)sender;
... get path from NSSavePanel ....
NSLog(@"%s got path \"%@\"",__FUNCTION__, path);
NSPrintInfo *printInfo = [ self printInfo ];
[ printInfo setJobDisposition: NSPrintSaveJob ];
NSMutableDictionary *dictionary = [ printInfo dictionary ];
[ dictionary setObject: path forKey: NSPrintSavePath ];
[ dictionary setObject: [ NSNumber numberWithBool: YES ] forKey:
NSPrintAllPages ];
NSLog(@"%s dictionary %@",__FUNCTION__, dictionary);
NSPrintOperation *po = [ NSPrintOperation printOperationWithView:
textView printInfo: printInfo ];
[ po setShowsPrintPanel: NO ];
[ po setCanSpawnSeparateThread: YES ];
NSLog(@"%s NSPrintOperation %@",__FUNCTION__, po);
NSLog(@"%s will runOperationModalForWindow for %@",__FUNCTION__,
[ textView window ]);
[ po runOperationModalForWindow: [ textView window ]
delegate: self
didRunSelector: @selector
( printOperationDidRun:success:contextInfo: )
contextInfo: NULL
];
NSLog(@"%s printing \"%@\"",__FUNCTION__, path);
}
- (void)printOperationDidRun:(NSPrintOperation *)printOperation
success:(BOOL)ok contextInfo:(void *)contextInfo
{
if ( !ok ) // error
{
NSLog(@"%s Error in:
runOperationModalForWindow:delegate:didRunSelector:contextInfo
:",__FUNCTION__);
return;
};
NSPrintInfo *printInfo = [ printOperation printInfo ];
NSMutableDictionary *dictionary = [ printInfo dictionary ];
NSString *path = [ dictionary objectForKey: NSPrintSavePath ];
NSLog(@"%s printed \"%@\"",__FUNCTION__, path);
NSLog(@"%s printInfo %@",__FUNCTION__, printInfo);
return;
}
====== the output ========
-[GymDocument printIt:] got path "/private/var/folders/+s/
+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading 1...4.pdf"
-[GymDocument printIt:] dictionary {
NSBottomMargin = 41;
NSCopies = 1;
NSDetailedErrorReporting = 0;
NSFaxNumber = "";
NSFirstPage = 1;
NSHorizonalPagination = 2;
NSHorizontallyCentered = 1;
NSJobDisposition = NSPrintSaveJob;
NSJobSavingFileNameExtensionHidden = 0;
NSJobSavingURL = "file://localhost/var/folders/+s/+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading 1...4.pdf
";
NSLastPage = 2147483647;
NSLeftMargin = 18;
NSMustCollate = 1;
NSOrientation = 0;
NSPagesAcross = 1;
NSPagesDown = 1;
NSPaperName = "iso-a4";
NSPaperSize = "NSSize: {595, 842}";
NSPrintAllPages = 1;
NSPrintProtected = 0;
NSPrintTime = "0001-01-01 06:42:04 +064204";
NSPrinter = "{\n \"Device Description\" = {\n
NSDeviceIsPrinter = YES;\n };\n \"Language Level\" = 2;\n
Name = \" \";\n Type = \"\";\n}";
NSPrinterName = " ";
NSRightMargin = 18;
NSSavePath = "/var/folders/+s/+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/
Reading 1...4.pdf";
NSScalingFactor = 1;
NSTopMargin = 18;
NSVerticalPagination = 0;
NSVerticallyCentered = 1;
}
-[GymDocument printIt:] NSPrintOperation <NSConcretePrintOperation:
0x1158392e0>
-[GymDocument printIt:] will runOperationModalForWindow for <NSWindow:
0x100191b40>
-[GymDocument printIt:] printing "/private/var/folders/+s/
+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading 1...4.pdf"
Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x00007fff82b5843e in blockForLocation ()
#1 0x00007fff82b59c80 in -[NSRLEArray objectAtIndex:effectiveRange:] ()
#2 0x00007fff82b5fb25 in -[NSConcreteMutableAttributedString
attribute:atIndex:effectiveRange:] ()
#3 0x00007fff83caa931 in -[NSConcreteTextStorage
attribute:atIndex:effectiveRange:] ()
#4 0x00007fff83cb813c in -[NSLayoutManager locationForGlyphAtIndex:] ()
#5 0x00007fff83cb6272 in -[NSLayoutManager(NSPrivate)
_drawGlyphsForGlyphRange:atPoint:parameters:] ()
#6 0x00007fff83c7b1a4 in -[NSTextView drawRect:] ()
#7 0x00007fff83c7a836 in -[NSTextView _drawRect:clip:] ()
#8 0x00007fff83c00c10 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#9 0x00007fff83c0159b in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#10 0x00007fff83c0159b in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#11 0x00007fff83c0159b in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#12 0x00007fff83c0159b in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#13 0x00007fff83c001f3 in -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#14 0x00007fff83bfca97 in -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] ()
#15 0x00007fff83b76237 in -[NSView displayIfNeeded] ()
#16 0x00007fff83b710e3 in _handleWindowNeedsDisplay ()
#17 0x00007fff84a2f437 in __CFRunLoopDoObservers ()
#18 0x00007fff84a0b6e4 in __CFRunLoopRun ()
#19 0x00007fff84a0b03f in CFRunLoopRunSpecific ()
#20 0x00007fff82552c4e in RunCurrentEventLoopInMode ()
#21 0x00007fff825529b1 in ReceiveNextEventCommon ()
#22 0x00007fff8255290c in BlockUntilNextEventMatchingListInMode ()
#23 0x00007fff83b46520 in _DPSNextEvent ()
#24 0x00007fff83b45e89 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#25 0x00007fff83b0ba7d in -[NSApplication run] ()
#26 0x00007fff83b04798 in NSApplicationMain ()
#27 0x0000000100001341 in main (argc=1, argv=0x7fff5fbff5b8) at /
Volumes/เม่น/Users/gerriet/Source/Stuff 10.4.8/Gymnure/main.m:13
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden