NSGraphicsContext PDF crash
NSGraphicsContext PDF crash
- Subject: NSGraphicsContext PDF crash
- From: Wesley Smith <email@hidden>
- Date: Mon, 3 Jan 2011 16:10:43 -0800
I'm trying to figure out why I get a crash when drawing to a PDF CG
context. From what I can tell, some resources are either corrupt or
missing, but it's not easy to tell from the docs since I'm doing
nothing complex and following the sample code on the apple website.
All of this code lives in a shared library. I have no NSWindow or
NSView. Instead, I created an NSGraphicsContext from a CGContextRef
as follows:
CGContextRef cgctx = CGPDFContextCreateWithURL(
url,
&cgrect,
NULL
);
if(cgctx) {
ctx = [NSGraphicsContext graphicsContextWithGraphicsPort:cgctx flipped:NO];
}
Then, I do
[NSGraphicsContext setCurrentContext:ctx];
[[NSColor blackColor] set];
NSBezierPath *p = [[NSBezierPath bezierPath] retain];
[p lineToPoint:NSMakePoint(100, 100)]; // <----------------- crashes here
[p stroke];
Top of the stack on crash:
#0 0x1726448f in PDFContentStreamDrawPath
#1 0x17264ec6 in pdf_DrawPath
#2 0x9845f545 in rips_DrawPath
#3 0x900dd7af in CGContextDrawPath
#4 0x900dd6fa in CGContextFillPath
#5 0x9009db5c in CGContextFillRect
#6 0x9087b072 in CUIRenderer::DrawWindowFrameDark
#7 0x9087dc2f in CUIRenderer::Draw
#8 0x92f06230 in _NSDrawThemeBackground
#9 0x92fcd63b in -[NSGrayFrame drawWindowBackgroundRegion:]
<snip>
Is there something else I have to do to initialize the PDF file-based
context? I'm bewildered.
thanks,
wes
_______________________________________________
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