LayoutManager & threads
LayoutManager & threads
- Subject: LayoutManager & threads
- From: Simon Bovet <email@hidden>
- Date: Thu, 10 Apr 2003 13:57:19 +0200
How can I make the following code thread-safe? (called while focused on
a NSImage created by the same thread)
...
1 NSTextStorage *textStorage = [[[NSTextStorage alloc]
initWithAttributedString:inAttributedString] autorelease];
2 NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init]
autorelease];
3 [textStorage addLayoutManager:layoutManager];
4 NSTextContainer *container = [[[NSTextContainer alloc]
initWithContainerSize:NSMakeSize(margin, 1e6)] autorelease];
5 [layoutManager addTextContainer:container];
6 NSRange glyphRange = [layoutManager
glyphRangeForTextContainer:container];
...
When this is run in a secondary thread, the following exception is
raised after line 2, sometimes after line 3:
Exception raised during background layout: *** -[NSCFArray
objectAtIndex:]: index (0) beyond bounds (0)
I guess it's raised from the main thread, which btw does not do more
than displaying a dialog with a static text and an increasing progress
bar. The secondary thread then deadlock before on line 6. This happens
not systematically, but always at the same place. I guess someone with
some more experience could give a good piece of advice!
Thanks for any help!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.