Re: Problems with NSLayout addTextContainer
Re: Problems with NSLayout addTextContainer
- Subject: Re: Problems with NSLayout addTextContainer
- From: Douglas Davidson <email@hidden>
- Date: Thu, 31 Oct 2002 09:26:19 -0800
On Wednesday, October 30, 2002, at 09:52 PM, Steve Sheets wrote:
My text program is having errors, when I attempt to reflow the text,
but only the second time!
Let me explain. My application displays text in 3 column format on
mulitble pages, depending on the length of the text. So I create a
text storage and layout objects, then on the fly, create
container/text view pairs to add to the layout. Each column is 1/3 of
the page wide, and one page long. After I add pair using
addTextContainer, I call glyphRangeForBoundingRect to have the text
flow into the containers. I receive the
didCompleteLayoutForTextContainer method, and keep track of when the
text have enough containers/text views so to stop adding new pairs to
the layout. Everything works perfectly the first time window is
displayed. Then user changes a setting, and the text is reformed. I
remove the layout object from text storage, and release it (which
releases all the containers/text views). Then I create new layout, and
start filling in containers/text views. This is same code I use to
fill in first time. On the second pair of containers/text views, when
I call addTextContainer to add container to layout, I get the
following error:
2002-10-31 00:01:18.374 MyApp[3503] *** NSRunStorage,
_NSBlockNumberForIndex(): index (793) beyond array bounds (0)
2002-10-31 00:01:18.420 MyApp[3503] Exception raised during background
layout: *** NSRunStorage, _NSBlockNumberForIndex(): index (793)
beyond array bounds (0)
2002-10-31 00:01:18.428 MyApp[3503] *** NSRunStorage,
_NSBlockNumberForIndex(): index (793) beyond array bounds (0)
The funny thing is this code worked for awhile. As always, I was
messing with code to have correct appearance, and something broke!
Anyone have any suggestions or comments?
There is a bug in Jaguar which causes problems sometimes when the text
container and text view are set up in the a certain order. Take a look
at the TextEdit sources, at the addPage method; notice that the
textView's addSubview method is called before the text container is
added to the layout manager. If you do things the other way around,
there can be problems under certain circumstances on Jaguar. That
might be what you are seeing. If not, try to get a backtrace with bt
-[NSException raise].
Douglas Davidson
_______________________________________________
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.