Unhandled exception when re-enabling [SOLVED]

EXetoC

15-04-2010 02:23:21

Whenever i pressthe button named "EXIT", the if block in this function is called

void dai::MainMenu::mouseButtonClick(MyGUI::Widget* sender)
{
// temporary
if (sender->getName() == "EXIT")
{
/* it crashes on any of these calls, whichever is first */

//mExitConfirmationDialog->clearUserStrings(); // uncommenting this line causes a crash in <xtree> while iterating
mExitConfirmationDialog->setEnabled(true);
mExitConfirmationDialog->setVisible(true);
}
}

And if i then press any of the buttons in the message box so that it closes, and i then click "EXIT" again so that the if block is executed a second time, the application crashes.

Here is the code for creating the message box.
void dai::MainMenu::createButtons()
{
/*mExitConfirmationDialog = MyGUI::Gui::getInstance().createWidget<MyGUI::Message>(
"Message",
MyGUI::IntCoord(0, 0, 200, 200),
MyGUI::Align::Default,
"Popup",
"ExitConfirmation"
);*/

mExitConfirmationDialog = MyGUI::Message::createMessageBox("Message", "", "A game is still in progress. Exit anyway?",
MyGUI::MessageBoxStyle::IconWarning | MyGUI::MessageBoxStyle::Yes | MyGUI::MessageBoxStyle::No,
"Popup", true);

mExitConfirmationDialog->setEnabled(false);
mExitConfirmationDialog->setVisible(false);
}

commenting the call to createMessageBox and uncommenting the call to createWidget results in the same outcome.

I've also tried doing this after creating the message box just to see if enabling the button and/or making it visible twice is what's causing this.

mExitConfirmationDialog->setEnabled(false);
mExitConfirmationDialog->setVisible(false);
mExitConfirmationDialog->setEnabled(true);
mExitConfirmationDialog->setVisible(true);
mExitConfirmationDialog->setEnabled(true);
mExitConfirmationDialog->setVisible(true);

And the outcome is once again the same as before, so i'm not sure what is going on.


I don't know if this might be of any help, but somewhere down the line, the mWidgetText pointer in mExitConfirmationDialog changes its value to "0xfeeefeee", which, according to someone on the gamedev.net forums, means this "Freed memory set by NT's heap manager"

my.name

15-04-2010 09:16:18

The MessageBox is automatically destroyed.

EXetoC

15-04-2010 12:48:18

Oh i see. I first thought that that might've been the case, but then i thought, why would it be designed like that? Now that i think of it, it makes the interface a bit simpler and it minimizes the calls that the client has to make.

Alright, thanks for the help.