It all seems to be stable now, so turning off background layout worked :-)

Thanks

Independent Cocoa Developer, Macatomy Software
http://macatomy.com


On 2009-12-23, at 9:45 AM, Douglas Davidson wrote:

> 
> On Dec 22, 2009, at 6:07 PM, PCWiz wrote:
> 
>> The issue class in my case is NSLayoutManager. I dug through the docs for 
>> NSLayoutManager and read the section on thread safety. There were 2 steps to 
>> achieving thread safety with NSLayoutManager. First, if the NSLayoutManager 
>> belonged to an NSTextView, then the text view must not be displayed while a 
>> secondary thread is making changes using its layout manager. The second part 
>> was to turn off background layout for the NSLayoutManager.
>> 
>> In my case the layout manager was not tied to a text view (I was just using 
>> it to get the size of an attributed string) so all I had to do was this:
>> 
>> [layoutManager setBackgroundLayoutEnabled:NO];
> 
> Those are the two criteria I specified in the release notes as being 
> essential for using NSLayoutManager on a background thread.  In general, an 
> NSLayoutManager and associated objects can be used from only a single thread 
> at once, but as long as you have eliminated simultaneous accesses to them 
> from other threads, they should be OK.  The tricky part is that view display 
> and background layout will happen automatically on the main thread, so you 
> need to make sure those will not occur for your layout manager while you are 
> using it on a background thread.  If you have done that and still see 
> threading issues, please file a bug.
> 
> Douglas Davidson
> 

_______________________________________________

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 arch...@mail-archive.com

Reply via email to