Dear list, I have an application which uses NSTextStorage objects to provide multiple views of the content of files. In principle, everything seems to be working fine; I can have multiple views of the same document and edit just fine. In most cases the text storage is initialized with some content, but in the case that the text storage is initialized with an empty string, I get exceptions the first time an attempt is made to insert a string using a NSTextView (calls to insertText:). The code that initializes the text storage is (simplified):
textStorage = [[NSTextStorage alloc] initWithString:str]; // Add a main layout manager NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; [textStorage addLayoutManager:layoutManager]; // Now add the container to the layout manager [layoutManager addTextContainer:textContainer]; // Clean up [textContainer release]; [layoutManager release]; [str release]; The exception I get is shown below. So as long as 'str' has at least one character in it, then I don't get the problems. I can then delete all in the text view and then type and all is well - just if I start from an empty text storage ... Any advice or clues would be gratefully received. Best wishes, Martin p.s. the implementation of insertText: doesn't do much, and removing this method from the text view subclass doesn't fix the problem. HIToolbox: ignoring exception '*** NSRunStorage, _NSBlockNumberForIndex(): index (18446744073709551615) beyond array bounds (0)' that raised inside Carbon event dispatch ( 0 CoreFoundation 0x00007fff87282d24 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x00007fff843c90f3 objc_exception_throw + 45 2 CoreFoundation 0x00007fff87282b47 +[NSException raise:format:arguments:] + 103 3 CoreFoundation 0x00007fff87282ad4 +[NSException raise:format:] + 148 4 AppKit 0x00007fff80154d9e _NSBlockNumberForIndex + 86 5 AppKit 0x00007fff80155ceb -[NSLayoutManager textContainerForGlyphAtIndex:effectiveRange:] + 364 6 AppKit 0x00007fff801adb71 -[NSTextView(NSSharing) didChangeText] + 340 7 AppKit 0x00007fff801d35a8 -[NSTextView insertText:replacementRange:] + 2763 8 TeXnicle 0x000000010001e85e -[TPTextView insertText:] + 199 9 AppKit 0x00007fff801d2a95 -[NSTextInputContext insertText:replacementRange:] + 345 10 AppKit 0x00007fff801d0eb1 -[NSTextInputContext handleTSMEvent:] + 2204 11 AppKit 0x00007fff801d0606 _NSTSMEventHandler + 156 12 HIToolbox 0x00007fff859dab57 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1002 13 HIToolbox 0x00007fff859da0a6 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 395 14 HIToolbox 0x00007fff859f7d85 SendEventToEventTarget + 45 15 HIToolbox 0x00007fff85a29417 SendTSMEvent + 48 16 HIToolbox 0x00007fff85a28fbd SendUnicodeTextAEToUnicodeDoc + 468 17 HIToolbox 0x00007fff85a28d38 TSMKeyEvent + 604 18 HIToolbox 0x00007fff85a13880 TSMProcessRawKeyEvent + 1909 19 AppKit 0x00007fff801cf2fb -[NSTextInputContext handleEvent:] + 620 20 AppKit 0x00007fff801cf022 -[NSView interpretKeyEvents:] + 186 21 AppKit 0x00007fff801cedfb -[NSTextView keyDown:] + 819 22 AppKit 0x00007fff80140c3b -[NSWindow sendEvent:] + 8769 23 AppKit 0x00007fff80075662 -[NSApplication sendEvent:] + 4719 24 AppKit 0x00007fff8000c0aa -[NSApplication run] + 474 25 AppKit 0x00007fff80004d7c NSApplicationMain + 364 26 TeXnicle 0x0000000100006e4d main + 33 27 TeXnicle 0x0000000100001354 start + 52 28 ??? 0x0000000000000001 0x0 + 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _______________________________________________ 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