Cannot unload layout

razali2k5

23-05-2010 19:49:50

For some reason the code that I normally use to unload a layout does not work in one instance. So this is how I initialize and setup the GUI for the console:

MyGUI::OgreRenderManager::getInstance().setSceneManager(mSceneMgr);
mGUI = MyGUI::Gui::getInstancePtr();
mGUI->setVisiblePointer(false);

mConsoleLayout = MyGUI::LayoutManager::getInstance().load("Console.layout");
mConsoleWindow = mGUI->findWidget<MyGUI::Window>("ConsoleWindow");
mConsoleWindow->eventWindowButtonPressed = newDelegate(this, &PlayState::notifyWindowButtonPressed);
mListHistory = mGUI->findWidget<MyGUI::Edit>("ConsoleWindow_HistoryList");
mComboCommand = mGUI->findWidget<MyGUI::ComboBox>("ConsoleWindow_CommandCombo");
mButtonSubmit = mGUI->findWidget<MyGUI::Button>("ConsoleWindow_SubmitButton");


and when I want to unload the layout I use this code
mConsoleWindow->setVisibleSmooth(false); // Hack because the layout is not getting unloaded correctly
MyGUI::LayoutManager::getInstancePtr()->unloadLayout(mConsoleLayout);
mConsoleLayout.clear();


I have to manually make it invisible. It is also inconvenient because when I rerun the first part of the code I pasted here, it keeps all of the information from the old console (which surely means it is not unloading it). What could be wrong?

Thanks!

razali2k5

23-05-2010 22:36:56

It turns out I was running the GUI initialization twice.