Laurent Defert Simonneau wrote:

I have commited the code i have written for the main menu using paragui.
But, there is a weird bug i can't find, so if someone want to have a
look, it would be great :)
It happens in the loop of the menu and/or in the callback function
(menu/main_menu.cpp - lines 71 to 80):
The callback functions of the buttons are called without any problem
(debug message displayed to the screen), but the variable corresponding
to the clicked button is overwritten, i don't know where, just after
leaving the callback function...
With gdb, i'm unable to trace/catch anything... With valgrind it crashes
when displaying the menu...
It may be a bad initialisation or a bad use of a paragui function, but
all the code is almost a copy of the dblbuffer exemple..
It seems to me, that it's caused by an overwritten stack, hard to trace
because of the threads :/
Ok don't panic I have just checked that you were printing the variable choice of the same objects :

*** src/menu/main_menu.cpp at line 71:
bool sig_play()
{ menu.choice=menuPLAY;printf("\nsig %d [%p]",menu.choice,&menu);return true;}

*** and src/menu/main_menu.cpp at line 165: printf("\n%d [%p]",choice, this);

And... you can see that you don't affect the choice variable of the same object as you read it.

0 [0x81356f0]
0 [0x81356f0]
0 [0x81356f0]
sig 1 [0x8060cac]
0 [0x81356f0]
0 [0x81356f0]

In fact the variable is not overwritten but affected to the global object menu but the object used in the main loop to determine the choice is another one :

file src/main.cpp at line 257:

      Menu *menu = new Menu;
      menu->Init();
      choix = menu->Run();

It is one that is dynamically allocated in the main program

Hope that You don't have spended too much time on it  ;-)



--
Jean-Christophe Duberga - http://jeanchristophe.duber.free.fr
webmaster du site MNEA  - http://www.mnea.fr


Répondre à