Page 1 of 1
System::injectMouseButtonUp() crashes when deleting GUI
Posted: Sun Mar 11, 2007 01:23
by some_name
I have a button in a window which, when clicked, causes state to change, which causes the current GUI to be disposed and the GUI sheet reset to NULL. This causes the function injectMouseButtonUp() to crash sometime after the event has been dispatched and my action taken.
Is this a known bug? The documentation for the injection functions say nothing about it not being OK to change the GUI configuration inside any callbacks/events.
Posted: Sun Mar 11, 2007 12:47
by scriptkid
Hi,
is that the injectMouseButtonUp which creates the click, or a new one? I hope this question is clear. Because a click 'ends' an event, so you should be able to cleanup windows, even the clicked one. Maybe you can post some code?
Posted: Tue Mar 13, 2007 23:30
by some_name
It is the inject that creates the HandleClicked callback.
The code looks something like the below.
Creation:
Code: Select all
window_ = CEGUI::WindowManager::getSingleton().loadWindowLayout(
(CEGUI::utf8*)layout);
BuildWidgetList(window_);
void MyClass::BuildWidgetList(CEGUI::Window *window) {
if (window->getType() == "TaharezLook/Button") {
CEGUI::Event::Connection conn = window->subscribeEvent(
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&MyClass::HandleClicked, this));
connections_[window->getName()] = conn;
}
widgets_[window->getName()] = window;
for (size_t cnt = window->getChildCount(), i = 0; i < cnt; ++i) {
BuildWidgetList(window->getChildAtIdx(i));
}
}
mGUISystem->setGUISheet(window_);
gApplication->SetBuffered(true); // turns on event injection
Handling/destruction:
Code: Select all
bool MyClass::HandleClicked(CEGUI::EventArgs const &e) {
delete window_;
gApplication->SetBuffered(false);
mGUISystem->setGUISheet(0);
return true;
}
As far as I can tell, this is all kosher (except, possibly, for the call to setGUISheet(0)).
I'm still trying to make this work without crashing, so any pointers on what I'm trying to do would be helpful.
Posted: Wed Mar 14, 2007 13:24
by Levia
Dont delete CEGUI window with delete