Page 1 of 1

[Solved]Strange crash on button click

Posted: Mon Dec 20, 2010 04:59
by AlanDa
I got a strange crash when using a button to destroy its parent window.

I striped the code down but it's still crashing.

That's the code:

Code: Select all

      CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
      CEGUI::DefaultWindow* fWnd = (CEGUI::DefaultWindow*)winMgr.createWindow( "TaharezLook/FrameWindow", "WndTest" );
      fWnd->setWidth(CEGUI::UDim(0.0f, 800.0f));
      fWnd->setHeight(CEGUI::UDim(0.0f, 400.0f));


      CEGUI::DefaultWindow *btnAbort = (CEGUI::DefaultWindow*)winMgr.createWindow( "TaharezLook/Button", "WndTest/btnAbort");
      btnAbort->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.0f, 350.0f ), CEGUI::UDim( 0.0f, 350.0f ) ) );
      btnAbort->setSize( CEGUI::UVector2( CEGUI::UDim( 0.0f, 150.0f ), CEGUI::UDim( 0.0f, 25.0f ) ) );
      btnAbort->subscribeEvent("Clicked", CEGUI::Event::Subscriber(&GUI::onTestAbortClicked));
      fWnd->addChildWindow(btnAbort);

      fWnd->subscribeEvent("CloseClicked", CEGUI::Event::Subscriber(&GUI::onTestAbortClicked));
      
      myRoot->addChildWindow(fWnd);


My onTestAbortClicked func is simply

Code: Select all

myRoot->getChild("WndTest")->destroy();


The strange thing is that the CloseClicked event destroys the window while the button clicked event crashes the app.
The crash is @ CEGUIBase.dll @ offset 0x000040e0 which is inside the CEGUI::Listbox::testClassName_impl function. No clue what's going on.
I'm using CEGUI 0.6.2.

Any help would be much appreciated.

Edit: Well.. the crash is gone. It was prolly MSVC' fault. Not sure tho.