On Jul 28, 2008, at 2:42 AM, Ken Ferry wrote:

Graham's suggestion is also better because -[NSGraphicsContext
setCurrentContext:] just releases the context that was previously
current, as opposed to autoreleasing it.

So this has a bug:

NSGraphicsContext *originalContext = [NSGraphicsContext currentContext];
[NSGraphicsContext setCurrentContext:newContext]; // bad!
originalContext may get deallocated here

// do stuff

[NSGraphicsContext setCurrentContext:originalContext];


Maybe I'm just misunderstanding what saveGraphicsState does, behind the scenes, but I actually need to draw into the passed in CGPDFContext, not any sort of view/image/winbow context. Best I can figure, this requires a forced context switch, not just saving and restoring the graphics state of whatever context happens to be current.

I couldn't find any way to draw into a CGGraphicsContext with NSxxx drawing commands without first creating a new context from the CGContext and second manually setting this context to be the current one. Is there a better/cleaner way?


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to