Deleting windows on button click

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Blakharaz
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Wed Jan 12, 2005 12:06
Location: Potsdam, Germany
Contact:

Deleting windows on button click

Postby Blakharaz » Thu Oct 28, 2004 02:49

Oops, didn't log in.

The window manager is already there, but is the idle thread thing really necessary or is there another method of destroying windows?
Coder in the Pantheon Team - creators of "Rastullahs Lockenpracht" (http://www.rastullahs-lockenpracht.de/)

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Deleting windows on button click

Postby CrazyEddie » Thu Oct 28, 2004 09:17

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.

User avatar
placebo
Just popping in
Just popping in
Posts: 3
Joined: Wed Jan 12, 2005 12:06

Deleting windows on button click

Postby placebo » Tue Nov 16, 2004 16:44

I ended up writing a Window Manager (just a simple list) and custom window classes for each window I make in the app. Then when a window is to be deleted, it hides, deactivates, and sets my custom window classes isDestroyable flag to true, then the Window Manager can clean it up during idle time.


I have the same window destroying problem and I wanted to know how to do something during idle time ? How can I know that it's idle time ?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Deleting windows on button click

Postby CrazyEddie » Thu Nov 25, 2004 11:40

Idle time is just time when you're not doing anything else. Only you can know when this might be for your particular project.

CE.

User avatar
thumperj
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Wed Jan 12, 2005 12:06
Location: Austin, TX
Contact:

Deleting windows on button click

Postby thumperj » Mon Nov 29, 2004 16:03

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! :D 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

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Deleting windows on button click

Postby CrazyEddie » Tue Nov 30, 2004 11:21

Hi,

Thanks, it was very nice to get away from CEGUI for a while ;)

Please feel free to submit a patch to the tracker. I can't promise I'll use such an approach over the "dead list" / deferred destruction idea, but at least there would be something for people to use while I sort things out :)

I suspect that your approach involves stopping calls to subscribed listeners when one of them returns true; I currently think this has potential to cause major issues since the event system is supposed to guarantee that all listeners get called (obviously in the case of a window being destroyed it is not important, though in other, possible unknown, cases it could be important that all other listeners get called even though a previously called listener has already indicated the event as handled).

Anyway, as I say, submit the changes because until a final decision is made there's probably many people who would benefit from a functioning system that allows window destruction to be triggered from events.

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests