squeaking for help!

Bob Arning arning at charm.net
Thu Jun 20 17:44:28 UTC 2002


On Thu, 20 Jun 2002 20:16:05 +0300 (IDT) Mayer Goldberg <gmayer at cs.bgu.ac.il> wrote:
>fillWhite
>	| whiteColor |
>	whiteColor := (Color r: 1.0 g: 1.0 b: 1.0)
>			     pixelValueForDepth: self depth
>	1 to: self bits do: [:i | self pixelValueAt: i put: whiteColor].
>
>But alas, this didn't work: I get an error: Improper store into
>indexable object... I tried moving up and down in the debugger, but I
>couldn't tell anything useful beyond the fact that the error occurred
>in pixelValueAt:put: ... The problem *I* am having is that right after
>I attempt to change the pixel value, I jump to another method
>SmallInteger>><= and I can't tell who invoked it! I tried to
>single-step, but got a "code simulation error" -- another ball game
>altogether.

The problem is that instead of

	1 to: self bits do:

you want

	1 to: self bits size do:

The reason the debugger was having difficulty showing you the exact location of the error is that the #to:do: message is optimized out and replaced with inlined code involving #<= amd #+ neither of which correspond to a specific bit of source that you wrote.

Once you fix this, you will discover that

- #pixelValueAt:put: takes a Point as the first argument, not an integer
- "self bits size" gives the number of 32-bit words in the bitmap, not the number of pixels.

Cheers,
Bob



More information about the Squeak-dev mailing list