[fixed]Empty ListBox Bug when pressing end -> any character

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

[fixed]Empty ListBox Bug when pressing end -> any character

Post by porcus »

There's a bug with empty ListBoxes:
If you press the end button and after that any character button in a focused empty ListBox it will crash.
This ist because of the following code in CGUIListBox.cpp (CGUIListBox::OnEvent) :

Code: Select all

                if (Selected >= (s32)Items.size())
                    Selected = Items.size() - 1;
                else
                if (Selected<0)
                    Selected = 0;
 
To fix it replace it with:

Code: Select all

                if(Selected<0){
                    Selected = 0;
                }
                if(Selected>=(s32)Items.size()){//no else here!
                    Selected = Items.size()-1;//becomes -1 now if no items
                }
Originally Selected wasn't -1 after pressing end although there are no items in the ListBox. The code handling a pressed character button expects Selected to be -1 if there's no selected item (therefore the crash).
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Empty ListBox Bug when pressing end -> any character

Post by CuteAlien »

Thanks for reporting and the patch. I've added it to the 1.8 branch in svn. I'll try to find time on the weekend to merge that with svn trunk.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [fixed]Empty ListBox Bug when pressing end -> any charac

Post by CuteAlien »

OK, finally merged into trunk.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply