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 PROTECTED]> 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 (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/kenferry%40gmail.com > > This email sent to [EMAIL PROTECTED] > _______________________________________________ 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]