• 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: LayoutManager & threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LayoutManager & threads


  • Subject: Re: LayoutManager & threads
  • From: Aki Inoue <email@hidden>
  • Date: Thu, 10 Apr 2003 12:32:15 -0700

Simon,

The background layout (which uses the main thread) is enabled by default.
Add [layoutManager setBackgroundLayoutEnabled:NO] after line 2.

Aki

On 2003.4.10, at 04:57 AM, Simon Bovet wrote:

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.
_______________________________________________
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.

References: 
 >LayoutManager & threads (From: Simon Bovet <email@hidden>)

  • Prev by Date: Re: Cocoa text rendering and setUsesScreenFonts: ATSUI? QuickDraw? Something else?
  • Next by Date: RE: NSMutableDictionary not sending release message to contained objects at dealloc time
  • Previous by thread: LayoutManager & threads
  • Next by thread: Drawing tiff images with transparency
  • Index(es):
    • Date
    • Thread