Skip navigation.
 
mlRe: Crash in lockFocus?
FROM : glenn andreas
DATE : Sun Jan 13 21:38:16 2008

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_removed>
  <http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next 
generation of fractal art

Related mailsAuthorDate
mlCrash in lockFocus? glenn andreas Jan 13, 20:52
mlRe: Crash in lockFocus? j o a r Jan 13, 21:06
mlRe: Crash in lockFocus? glenn andreas Jan 13, 21:38