proper way to handle close events


31-07-2007 13:50:37

id like to catch the button click of the X in the title bar, and i do so like this:


the event handler is called, at which point i'd like to actually remove all widgets associated with the window....and i do it like so:

bool closeEvent(const QuickGUI::EventArgs &args)
return true;

however, on the next update of my input handling, where i do:

mGuiManager->injectMouseMove( e.state.X.rel, e.state.Y.rel );

i get a crash that says:
unhandled exception... exception: std::bad_alloc at memory location 0x0012dfd8.. which happens somewhere in QUickGUI, but i cant see it...stems from the injection call though. I probably did something wrong, so any help would be appreciated.


31-07-2007 18:47:29

I believe the problem is that you are executing code of an object while the object is being deleted. For example, you tell the window to delete everything, but the event handler still needs to finish executing right? But the close button no longer exists? :?

I will make a proper way to delete widgets, and it will be via GUIManager. Basically the GUIManager will have a FreeList, and the function to destroy a widget just adds the widget to the list. Next Frame, I will delete all widgets queued on the free list, and make sure GUIManager doesn't reference any of these widgets. (mActiveWidget, mMouseOverWidget)

I will implement this for v0.9.6.


31-07-2007 20:52:44

makes sense, i eagerly await your next version :)