[BUG][FIX]TextStream nextPutAll:
Frits Swinkels
frits.swinkels at shaw.ca
Sun Sep 28 22:29:19 UTC 2003
I have another bug with the same cause. Text does not display itself
properly in ObjectExplorer; it shows the string but not the IV runs.
The cause is that Text is a subclass of SequenceableCollection which
overrides each and every bit of essential collection behavior (at: at:put:,
size, etc), a good example of proper OO design? No doubt this class, unless
reparented , will be good for many mysterious bugs for the years to come;)
At 01:27 PM 9/24/03, you wrote:
>Folks,
> Here is a surprising bug, and a fix for it. If you execute this:
>
>WW _ Workspace prototypicalToolWindow.
>WW openInWorld.
>(WW findA: PluggableTextMorph) editString: (Text streamContents: [:strm |
> 24 timesRepeat: [
> strm nextPutAll: 'This text is ' asText, 'bold ' asText
> allBold]])
>
>The Workspace will contain:
>This text is bold This text is bold This text is bold This text is bold
>This text is bold This text is bold This text is bold This text is bold
>This text is bold This text is bold This text is bold This text is bold
>This text is bold This text is bold This text is bold This text is bold
>This text is bold This text is bold This text is bold This text is bold
>This text is bold This text is bold This text is bold This text is bold
>
>Notice that the next to last 'bold' is NOT bold! How could this happen?
>
>In TextStream nextPutAll: the code calls super when the new text overflows
>the buffer collection. Super, however, treats the argument as a String,
>not as Text. It throws away the attribute information for that piece of text.
>
>Enclosed is a fix. It is from Squeak 3.2, but it will work in any modern
>version. I tested it in 3.7alpha.
>
>--Ted.
>
>
>--
>Ted Kaehler http://www.squeakland.org/~ted/
More information about the Squeak-dev
mailing list
|