Re: NSGraphicsContext restore crashes my xtension
Re: NSGraphicsContext restore crashes my xtension
- Subject: Re: NSGraphicsContext restore crashes my xtension
- From: email@hidden
- Date: Sun, 27 Jul 2008 18:33:57 +0000
-------------- Original message ----------------------
From: glenn andreas <email@hidden>
> restoreGraphicsState restores the state of the current context - it
> does not restore the context to the previous context. You need to
> explicitly save the current context before you do setCurrentContext:
>
> NSGraphicsContext *oldContext = [NSGraphicsContext currentContext];
> [NSGraphicsContext setCurrentContext: nsContext];
> ... do drawing in the nsContext (save/restoreGraphics state impacts
> internal variables of nsContext)
> [NSGraphicsContext setCurrentContext: oldContext];
>
I think part of the difficulty I'm having is that I'm using CGGraphicsContext for the bulk of the drawing but found the CGxxx styled text drawing too tedious so switch to NSGraphic context methods just to draw the text and then attempt to switch back to CGGraphicsContext
You'll note that I'm passing in a CGContextRef to drawImageTextInCGContext and creating a temporary context just for the text drawing with this line:
NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort: inContextRef flipped: NO];
By my (perhaps flawed) understanding, I'm really just using the passed in context with an NSGraphics context wrapper, no? Do I restore the passed in context? And if so, how?
_______________________________________________
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