Yeah this is a bit of a pain. The crash is due the the object being deleted while the event system is still iterating over the subscribed listeners.
Presently, maintaining a window "dead list" is about the only way to go. I've given this a little thought and I might integrate this approach into the CEGUI::WindowManager itself, though one drawback would be that the client code would then lose control over when the dead-list actually gets cleaned.
CE.
Hi, CE - Welcome back!

I hope your holiday was great!
In coding up my application I made a few small changes to CEGUI that enables me to close and destroy windows on a button click. The changes are in three places: CEGUISystem.cpp, CEGUIEvent.cpp, and CEGUIPushButton.cpp. The changes all revolve around checking to see if the event has been handled. For instance, in System.cpp::injectMouseButtonUp:
Code: Select all
while ((!ma.handled) && (dest_window != NULL))
{
ma.window = dest_window;
dest_window->onMouseButtonUp(ma);
if ( !ma.handled ) // if the message was handled, don't try and get parent
dest_window = dest_window->getParent();
}
The other changes are quite similiar. This way, when a button is clicked to close a window the handled flag is set and halts the iteration over the subscribed listeners. Thus, the window can be easily deleted inside a message handler and the stack unravels cleanly.
I'm using the heck out of it in my code.

Would you like me to submit the changes to the project tracker?
cheers,
Chris