dwt learning question,please help

Denis Koroskin 2korden at gmail.com
Tue Sep 2 13:33:50 PDT 2008


On Tue, 02 Sep 2008 02:24:20 +0400, Frank Benoit  
<keinfarbton at googlemail.com> wrote:

> Denis Koroskin schrieb:
>> On Mon, 01 Sep 2008 16:21:12 +0400, Frank Benoit
>> <keinfarbton at googlemail.com> wrote:
>>
>>> Denis Koroskin Wrote:
>>>
>>>> On Mon, 01 Sep 2008 12:37:31 +0400, Denis Koroskin <2korden at gmail.com>
>>>> wrote:
>>>>
>>>> > On Mon, 01 Sep 2008 11:32:36 +0400, Frank Benoit
>>>> > <keinfarbton at googlemail.com> wrote:
>>>> >
>>>> >> this code works for me.
>>>> >> I will install SP3 to see if i can reproduce the problem.
>>>> >
>>>> > I have the same bug, too. Windows 2003 Server
>>>>
>>>> More info:
>>>>
>>>> Tango backtrace hack intiated
>>>> Unhandled D exception!
>>>> Error: Array index out of bounds
>>>> (tango.core.Exception.ArrayBoundsException) in dwt.graphics.Image  
>>>> [715]
>>>> backtrace:
>>>>   004d5d51 onArrayBoundsError (+25)
>>>>   00404087 void resizeapp.MainForm.InitializeComponents(void*) (+67)
>>>> resizeapp.d:32
>>>>   00404290 class resizeapp.MainForm resizeapp.MainForm._ctor(void*)�
>>>> (+10)
>>>> resizeapp.d:79
>>>>   004042ab _Dmain (+17) resizeapp.d:86
>>>>   004d3041 extern (C) int dmain2.main(int, char**) . void  
>>>> runMain(void*)
>>>> (+d)
>>>>   004df062 mainCRTStartup (+aa)
>>>>   77e6f23c ???
>>>>   00000001 ???
>>>>
>>>> 712 RGB[] rgbs = new RGB[colorPalette.Count];
>>>> 713 paletteData = new PaletteData(rgbs);
>>>> 714 for (int i = 0; i < colorPalette.Count; i++) {
>>>> 715     if (((palette.Entries[i] >> 24) & 0xFF) is 0 &&
>>>> (colorPalette.Flags & Gdip.PaletteFlagsHasAlpha) !is 0) {
>>>> 716         transparentPixel = i;
>>>> 717     }
>>>> 718     rgbs[i] = new RGB(((palette.Entries[i] & 0xFF0000) >> 16),
>>>> ((palette.Entries[i] & 0xFF00) >> 8), ((palette.Entries[i] & 0xFF) >>
>>>> 0));
>>>> 719 }
>>>> 720 OS.HeapFree(hHeap, 0, palette);
>>>> 721 break;
>>>
>>>
>>> This was fixed in
>>> http://www.dsource.org/projects/dwt-win/changeset/302%3A555d58850cd9
>>> can you please retry with the newest tip version?
>>> http://hg.dsource.org/projects/dwt-win/archive/tip.zip
>>>
>>> Frank
>>
>> Ouch! Are you sure this fixes the issue and not hides it? It's quite
>> clear that the bug is somewhere else, colorPalette.Count ==
>> palette.Entries should always evaluate to true.
>
> you mean
> colorPalette.Count == palette.Entries.length
> ?
Yes, that was a typo.

>
> I think this is not true. It would be true if Entries would be an
> dynamic array. But it is static array, hence the length is always 1.
> But the real array /can/ be longer.
>
> struct ColorPalette {
>   int Flags;
>   int Count;
>   int[1] Entries;
> }
>
> To avoid the array bounds check i changed the code to use the pointer
> arithmetic.
>
> Does that make sense?

Ah, now yes. Thank you for explanation!


More information about the Digitalmars-d-dwt mailing list