[SOLVED] An exception has occured!

Buckcherry

23-12-2008 15:36:37

Hi everybody,

I am trying to create a button which shutdown MyGUI when it is clicked.

For that, I have this:

// Initialize MyGUI
mGuiMgr->initialise(mWindow);

// Button
MyGUI::ButtonPtr button = mGuiMgr->createWidget<MyGUI::Button>("Button", 10, 10, 300, 26, MyGUI::Align::Default/*MyGUI::ALIGN_DEFAULT - obsolete*/, "Main");
button->setCaption("exit");
button->eventMouseButtonClick = MyGUI::newDelegate(this, &LoginState::handleExitButtonClick);


The handleExitButtonClick method is:

void LoginState::handleExitButtonClick(MyGUI::WidgetPtr _sender)
{
mGuiMgr->shutdown();
delete mGuiMgr;
mGuiMgr = 0;

mInputMgr->removeKeyListener("loginKeyListener");
mInputMgr->removeMouseListener("loginMouseListener");

mWindow->removeAllViewports();

mRoot->destroySceneManager(mSceneMgr);
}


When I click on the button, the following exception is trhown:

OGRE EXCEPTION(10:MyGUIException): instance PointerManager was not created

Any idea?

Altren

23-12-2008 15:47:26

Well... it's not good idea to kill GUI inside GUI call. It's same as deleting this inside class member function and call another code from same instance.

Just mark some variable in your callback and then destroy your app in frameStarted.

Buckcherry

23-12-2008 22:03:04

Ok. Thank you very much!.