mettli / guichan

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

segmentation fault in gnc::Gui::distributeMouseEvent() #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, 

i was just experimenting a bit with guichan in combination with opengl, and
was happily working away at the tutorials. Most of my code has been
shamelessly plagiarized from said tutorials.

I have now a rotating glut solid cube, and a top container with a label and
two gcn::Button objects, Button1 and Button2. Both buttons have a
mouseListener, MyMouseListener. Whenever the mouse moves over either
button, the program crashes with a segfault.

What version of the product are you using? On what operating system? Which
back-end (SDL/Allegro/OpenGL/other)?
Version: 0.8.1-1, from the debian apt repositories
OS: Debian Lenny
SDL for input, OpenGL for graphics

Please provide any additional information below.

The GDB backtrace looked like this:

#4 0x0804ab89 in main() at main.cpp:185
#3 0xb7dbe073 in gcn::Gui::logic() at gui.cpp:146
#2 0xb7dbdedc in gcn::Gui::handleMouseInput() at gui.cpp:237
#1 0xb7dbd7ac in gcn::Gui::handleMouseMoved() at gui.cpp:469
#0 0xb7dbc04f in gcn::Gui::distributeMouseEvent() at gui.cpp:734 

I've attached my current code.

many thanks
Grasman

Original issue reported on code.google.com by gras...@zandbak.org on 13 Aug 2008 at 11:42

Attachments:

GoogleCodeExporter commented 9 years ago
It's crashing on the following line:

              (*it)->mouseEntered(mouseEvent);

Where (*it) is supposed to be your mouse listener, but the problem is, it 
isn't. In
your application you've allocated two MyMouseListener instances on the stack in
guichan_init(), which are automatically destroyed once this function exists.
Unfortunately, Guichan doesn't know about this, so it crashes while trying to 
tell it
about the entered event later on.

You already have plenty of global pointers to stuff allocated on the heap, so 
you
probably want your listeners among those too. However, note that anything you 
'new'
should normally also be deleted with 'delete'. There are currently no 
occurences of
'delete' in your application.

Original comment by b.lindeijer on 14 Aug 2008 at 8:55

GoogleCodeExporter commented 9 years ago
Whoops, i guess that'll teach me to get some sleep before thinking about 
submitting a
bug report. Many thanks for the kind response, it was entirely my own fault.

as for the deleting, once i get this working i'm changing all pointers to boost 
smart
pointers, but during programming the compiler errors one gets when using them,
especially in combination with other templates, tend to drive me crazy.

grts
Grasman

Original comment by gras...@zandbak.org on 15 Aug 2008 at 7:06

GoogleCodeExporter commented 9 years ago

Original comment by olof.nae...@gmail.com on 15 Aug 2008 at 7:18