System::injectMouseButtonUp() crashes when deleting GUI

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

some_name
Just popping in
Just popping in
Posts: 15
Joined: Sat Mar 10, 2007 00:12

System::injectMouseButtonUp() crashes when deleting GUI

Postby some_name » Sun Mar 11, 2007 01:23

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.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Sun Mar 11, 2007 12:47

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?

some_name
Just popping in
Just popping in
Posts: 15
Joined: Sat Mar 10, 2007 00:12

Postby some_name » Tue Mar 13, 2007 23:30

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.

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Wed Mar 14, 2007 13:24

Dont delete CEGUI window with delete :)
Image
Image


Return to “Help”

Who is online

Users browsing this forum: No registered users and 14 guests