• 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: "Ken Ferry" <email@hidden>
  • Date: Sun, 27 Jul 2008 23:42:22 -0700

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];

-Ken

On Sun, Jul 27, 2008 at 9:02 PM, Graham Cox <email@hidden> wrote:
>
> On 28 Jul 2008, at 11:05 am, Ken Tozier wrote:
>>
>> Saving/restoring the context with
>>
>> *oldContext = [NSGraphicsContext currentContext];
>>
>> [NSGraphicsContext setCurrentContext: oldContext];
>>
>> Did the trick. No more crashes.
>
>
> Since this is such a common thing to need to do, it's usually more
> convenient to just put:
>
> [NSGraphicContext saveGraphicsState];
>
> at the top of your code and
>
> [NSGraphicsContext restoreGraphicsState];
>
> at the bottom.
>
>
>
> Graham
> _______________________________________________
>
> 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
>
_______________________________________________

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: Ken Tozier <email@hidden>
References: 
 >Re: NSGraphicsContext restore crashes my xtension (From: email@hidden)
 >Re: NSGraphicsContext restore crashes my xtension (From: glenn andreas <email@hidden>)
 >Re: NSGraphicsContext restore crashes my xtension (From: Ken Tozier <email@hidden>)
 >Re: NSGraphicsContext restore crashes my xtension (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: NSPopupButton and bindings to NSArrayController
  • Next by Date: Setting conditional breakpoint on Cocoa method?
  • Previous by thread: Re: NSGraphicsContext restore crashes my xtension
  • Next by thread: Re: NSGraphicsContext restore crashes my xtension
  • Index(es):
    • Date
    • Thread