NSBitmapRep crashes during printing
NSBitmapRep crashes during printing
- Subject: NSBitmapRep crashes during printing
- From: Izidor Jerebic <email@hidden>
- Date: Wed, 27 Mar 2002 14:45:49 +0100
Hello!
I'm having a problem with creating and using NSBitmapImageRep, and I
really don't understand why. The application crashes during printing (or
any PDF generation) when an NSImage with bitmap is being printed. On
screen it works OK, no problems with redrawing, scrolling, etc...
The following code is minimalist example of what I do (note that in the
example I do not modify any pixel data - just creating the bitmap is
enough for crashing the app).
In the template Cocoa application I just subclassed NSView in
InterfaceBuilder, made class files for it with IB, created a view in
default window and set its class to MyView. The code below is complete
MyView.m copied from ProjectBuilder. Run the app and press Print... Crash
:-(
There must be something very obvious I am missing. Can anybody point out
that little thing, please?
TIA,
izidor
#import "MyView.h"
@implementation MyView
- (void)drawRect:(NSRect)r
{
static NSImage *image ;
if( image == nil ) {
NSBitmapImageRep *rep ;
rep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:100 pixelsHigh:100 bitsPerSample:8 samplesPerPixel:3
hasAlpha:NO isPlanar:YES colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:
100 bitsPerPixel:0] autorelease] ;
image = [[NSImage alloc] initWithSize:NSMakeSize(100,100)] ;
[image addRepresentation:rep] ;
[image setDataRetained:YES] ;
}
[super drawRect:r] ;
[[image bestRepresentationForDevice:nil] draw] ;
}
@end
---------------
Crash stack trace from gdb:
(gdb) where
#0 0x7722d7c0 in decode_destory ()
#1 0x7722d20c in decode_data ()
#2 0x771f0e3c in CGSRegisterGenericCls ()
#3 0x771d3944 in CGSImageStreamRead ()
#4 0x73ced888 in PDFImageEmitDefinition ()
#5 0x73ced0ac in PDFImageEmitDefinition ()
#6 0x7017cb10 in CFSetApplyFunction ()
#7 0x73cee028 in PDFImageSetEmitDefinitions ()
#8 0x73ce4cf8 in PDFDocumentEndPage ()
#9 0x73ce484c in PDFContentStreamClipToText ()
#10 0x771e736c in CGContextEndPage ()
#11 0x73876dc0 in Notify__FPC9CVBackEndPC13CVSessionInfoPv7CVEvent ()
#12 0x7366001c in PJCRegistry::Lock ()
#13 0x7367f908 in PMSessionEndPageNoDialog ()
#14 0x70e16d3c in -[NSTiogaGraphicsContext endPage] ()
#15 0x70d9af84 in -[NSView(NSPrinting) endPage] ()
#16 0x70d9810c in -[NSView(NSPrinting)
_doPageArea:finishPage:helpedBy:pageLabel:] ()
#17 0x70d988a8 in -[NSView(NSPrinting)
_printAndPaginateWithOperation:helpedBy:] ()
#18 0x70d982d0 in -[NSView(NSPrinting) _generatePSCodeHelpedBy:operation:]
()
#19 0x70d9943c in -[NSView(NSPrinting) _realPrintPSCode:helpedBy:] ()
#20 0x70cf91cc in -[NSConcretePrintOperation _doActualViewPrinting] ()
#21 0x70cfa26c in -[NSConcretePrintOperation runOperation] ()
#22 0x70c699d4 in -[NSWindow print:] ()
#23 0x70833b28 in -[NSObject performSelector:withObject:] ()
#24 0x70c94698 in -[NSApplication sendAction:to:from:] ()
#25 0x70bf9d7c in -[NSMenu performActionForItemAtIndex:] ()
#26 0x70c1d638 in -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:] ()
#27 0x70c7c3c4 in -[NSMenu performKeyEquivalent:] ()
#28 0x70b943a4 in -[NSApplication sendEvent:] ()
#29 0x70c23488 in -[NSApplication run] ()
#30 0x70c91ed0 in NSApplicationMain ()
#31 0x00003ac4 in main (argc=1, argv=0xbffffd20)
#32 0x000039e8 in _start ()
#33 0x00003818 in start ()
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.