• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSGraphicsContext restore crashes my xtension
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSGraphicsContext restore crashes my xtension
      • From: glenn andreas <email@hidden>
  • Prev by Date: Re: NSGraphicsContext restore crashes my xtension
  • Next by Date: Re: Web View silently fails
  • Previous by thread: Re: NSGraphicsContext restore crashes my xtension
  • Next by thread: Re: NSGraphicsContext restore crashes my xtension
  • Index(es):
    • Date
    • Thread