• 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: Crash in lockFocus?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash in lockFocus?


  • Subject: Re: Crash in lockFocus?
  • From: glenn andreas <email@hidden>
  • Date: Sun, 13 Jan 2008 14:38:16 -0600


On Jan 13, 2008, at 2:06 PM, j o a r wrote:

Hello,

Could this be a thread-safety problem? If you're using multiple threads, are you sure that you're playing by the (barely documented) rules?

j o a r


I am using threads (a lot, actually), but this has happened in the main thread (it was making a custom icon while saving) when there is nothing drawing anything on the secondary threads (calculating things, yes, but nothing that involves NSImages, or even any CG stuff).


That was my first guess, which is why I threw in the setCacheMode (which was more voodoo than anything). Plus, according to the archives <http://lists.apple.com/archives/Cocoa-dev/2001/Jul/msg01138.html >, "you can safely lockFocus from multiple thread" (and since that's all I'm doing with that NSImage, I believe I'm following the barely documented rules).

I could probably switch the code over to do the "create NSBitmapImageRep, clear it, create NSGraphicsContext & set it, set up parameters, draw" dance <http://lists.apple.com/archives/cocoa-dev/2007/Nov/msg01208.html > instead of the much simpler "lockFocus", which would probably avoid the problem, but require a lot of changes to get going... I should probably just bite the bullet and start searching my code for lockFocus and do a wholesale purge if I can't work this out.

[This would be one of those few times that I wish objective-c provided blocks like smalltalk so that you could define new control structures to wrap this up cleanly, but blocks would needs to be closures to be truly useful, and closures in a c-based language aren't practical]






Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next generation of fractal art




_______________________________________________

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


References: 
 >Crash in lockFocus? (From: glenn andreas <email@hidden>)
 >Re: Crash in lockFocus? (From: j o a r <email@hidden>)

  • Prev by Date: Re: Crash in lockFocus?
  • Next by Date: Re: Private Frameworks
  • Previous by thread: Re: Crash in lockFocus?
  • Next by thread: Pattern colors and alpha
  • Index(es):
    • Date
    • Thread