• 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
NSTextStorage: Deadlock
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextStorage: Deadlock


  • Subject: NSTextStorage: Deadlock
  • From: Basil Achermann <email@hidden>
  • Date: Wed, 3 Mar 2004 16:04:44 +0100

Hi,

I have an application with two threads, a main (GUI input) thread and a
worker thread which does some processing and occasionally updates
values in one of the application's NSTextViews. However, the app
frequently hangs if the text which is about to be replaced is currently
selected.

Here's some simplified code in order to illustrate the problem:


// - worker thread:
// - consoleView is of type NSTextView*
// - [str length] == range.length (in fact, it's even the same string
that's already there)
// - sRange.location < range.location

while (1) {
[[consoleView textStorage] replaceCharactersInRange:range
withAttributedString:str];
[consoleView setSelectedRange:sRange];
}


That program usually hangs after a fraction of a second. Here's what
happens (inverse call stack):

worker:
...
120 -[NSConcreteMutableAttributedString
replaceCharactersInRange:withAttributedString:]
120 -[NSTextStorage edited:range:changeInLength:]
120 -[NSTextStorage processEditing]
120 -[NSTextStorage
_notifyEdited:range:changeInLength:invalidatedRange:]
120 -[NSLayoutManager
textStorage:edited:range:changeInLength:invalidatedRange:]
120 -[NSLayoutManager(NSPrivate)
_fixSelectionAfterChangeInCharacterRange:changeInLength:]
120 -[NSTextView(NSSharing) setSelectedRange:affinity:stillSelecting:]
120 -[NSLayoutManager invalidateDisplayForCharacterRange:]
120 -[NSLayoutManager glyphRangeForCharacterRange:actualCharacterRange:]
120 -[NSLayoutManager(NSPrivate)
_glyphRangeForCharacterRange:actualCharacterRange:okToFillHoles:]
120 -[NSLayoutManager(NSPrivate)
_glyphIndexForCharacterIndex:startOfRange:okToFillHoles:]
120 _NSFastFillAllGlyphHolesUpToGlyphIndex
120 -[NSRecursiveLock lock]
120 _pthread_cond_wait
120 semaphore_wait_signal_trap
120 semaphore_wait_signal_trap

main:
...
120 +[NSLayoutManager(NSPrivate) _doSomeBackgroundLayout]
120 -[NSLayoutManager(NSPrivate)
_fillLayoutHoleAtIndex:desiredNumberOfLines:]
120 -[NSConcreteTextStorage _lockForReading]
120 -[NSViewHierarchyLock lockForReadingWithExceptionHandler:]
120 _pthread_cond_wait
120 semaphore_wait_signal_trap
120 semaphore_wait_signal_trap

Deadlock?!!
The same also happens if the text is selected manually (after some
time). If sRange == range, everything works fine. Also, if there's no
selection at all. Does anybody have an idea why this happens and what
can be done about it?

TIA,
b
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSTextStorage: Deadlock
      • From: Satoshi Matsumoto <email@hidden>
    • Re: NSTextStorage: Deadlock
      • From: Aki Inoue <email@hidden>
    • Re: NSTextStorage: Deadlock
      • From: Stefan Pantke <email@hidden>
  • Prev by Date: Re: NSButton darkens background when pressed
  • Next by Date: Re: Changing NSTableView cell editing behaviour
  • Previous by thread: Re: Thanks for the TableView hint.
  • Next by thread: Re: NSTextStorage: Deadlock
  • Index(es):
    • Date
    • Thread