paragui-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-users] problem when deleting widgets


From: Robby Dermody
Subject: [paragui-users] problem when deleting widgets
Date: Tue, 10 Sep 2002 11:25:27 -0400

Hi I have a problem that's quite complex....

In my application, I've created a sort of finite state machine with my menu
system (it's a client for a game). Each menu screen is a GuiState object
derived from PG_Widget, which loads a layout and is the parent of the
widgets in this layout (mostly buttons). I use the C style callbacks for the
mouseclick events for these buttons. The problem comes when I click on a
button to advance to a new menu screen. What happens is that the button's
callback calls a switchState method in a manager class, which creates a new
GuiState object, assigns this GuiState as the current state, and then
destroys the old state, which destroys all the attached child objects
(including the button which was clicked to initialize this).

Stepping through the program, it seems that the SDL mousedown and mouseup
events are processed fine, but there is some extra mouseup event that
triggers PG_MessageObject::SendMessage() where 'this' is the triggering
PGButton, AFTER the old GuiState has been destroyed (and the memory address
is invalid), causing a segfault. This is under windows XP using MS Visual
Studio .NET BTW. I've tried most everything, including telling the button
not to process events anymore, trying to pump the event queue clean before I
delete the widget, etc. If I don't delete this old widget, it works fine,
but obviously I'm memleaking in that case.
Statement it segfaults on is:

// object to call
if(cbdata->calledobj != NULL) {
--> rc = ((cbdata->calledobj)->*(cbdata->obj_cbfunc))(id, (PG_Widget*)this,
data, cbdata->data);
}


Locals of interest:

- cbdata 0x00f61260 PG_EVENTHANDLERDATA *
   cbfunc 0xfeeefeee bool (int, PG_Widget *, unsigned long, void *)*
   obj_cbfunc 0xfeeefeee bool (int, PG_Widget *, unsigned long, void *)*
+ calledobj 0xfeeefeee PG_EventObject *
    data 0xfeeefeee void *
+ cbdata->calledobj 0xfeeefeee PG_EventObject *


The function call stack is:

  feeefeee()
> client.exe!PG_MessageObject::SendMessage(PG_MessageObject *
target=0x00f60ca8, PG_MSG_TYPE type=MSG_BUTTONCLICK, unsigned long id=0,
unsigned long data=0)  Line 446 + 0x27 C++
  client.exe!PG_Button::eventMouseButtonUp(const SDL_MouseButtonEvent *
button=0x0012fc34)  Line 375 C++
  client.exe!PG_MessageObject::ProcessEvent(const SDL_Event *
event=0x0012fc34)  Line 143 + 0x11 C++
  client.exe!PG_MessageObject::PumpIntoEventQueue(const SDL_Event *
event=0x0012fc34)  Line 319 + 0x17 C++
  client.exe!GuiState_Menu::ProcessEvent(SDL_Event & Event={...})  Line 273
+ 0x1b C++
  client.exe!Application::Run()  Line 152 + 0x32 C++
  client.exe!main()  Line 138 C++
  client.exe!mainCRTStartup()  Line 259 + 0x19 C
  kernel32.dll!77e7eb69()



Thanks for any help, or ideas I might want to try,

Robby

Robby Dermody   <address@hidden> <AIM: robbyd523>
Where everyone goes, the grass never grows.  (Irish Proverb)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]