littleflylongbow / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

ListBox inside a ScrollArea crashes application #138

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Download attached font image and code
2. Compile the code:
g++ -o testguichan testguichan.cpp `sdl-config --cflags --libs` -lSDL_image 
-lguichan -lsdl_guichan
3. Run testguichan and try scrolling down the list

What is the expected behaviour? What happens instead?
ListBox should show all of its contents scrolling up/down as required by the 
clipping area of ScrollArea, but it crashes when reaching last element 
(sometimes some other element) in the list.

What version of the product are you using? On what operating system? Which 
back-end (SDL/Allegro/OpenGL/other)?
guichan 0.8.2-1, Ubuntu, SDL.

Please provide any additional information below.
Attached code crashes with a segmentation fault when scrolling down either with 
the scroll bars or using the keyboard (having the ListBox focused). Change 
scroll area width to 150 and it will work. Then add a seventh element to the 
list and it crashes again.

Does anyone have an idea of why is this happening and how to solve it? Thanks 
in advance for your help.

Original issue reported on code.google.com by josejo...@gmail.com on 26 Jan 2011 at 6:37

Attachments:

GoogleCodeExporter commented 8 years ago
Run it with a debugger (gdb) and find out where it crashes.

Original comment by olof.nae...@gmail.com on 26 Jan 2011 at 10:51

GoogleCodeExporter commented 8 years ago
Hi, thanks for your reply, I've run it using gdb and found out that you were 
correct: it is an out of bounds error, MyListModel::getElementAt(i) is called 
with an i equal to the elements in the list, I've added this protection code to 
MyListModel::getElementAt

std::string getElementAt( int i )
{
  if ( i >= mList.size() )
  {
    return "ERROR/EMPTY";
  }
  else
  {
    return mList[ i ]; }
  }
}

Also, I would like to know whether guichan is still being actively maintained.

Thanks a lot for your help.

Original comment by josejo...@gmail.com on 27 Jan 2011 at 6:32

GoogleCodeExporter commented 8 years ago
Guichan is not really actively maintained anymore. Sometimes a patch is 
submitted.

Original comment by olof.nae...@gmail.com on 28 Jan 2011 at 9:51

GoogleCodeExporter commented 8 years ago
Here is a patch which fixed it for me.

Original comment by josh.sic...@gmail.com on 12 Dec 2013 at 10:03

Attachments: