I'm having troubles to write a clean and safe function that switches between two GUIs.
I precise that my program is NOT multithreaded. And I use only Irrlicht to handle inputs/GUI events.
I have something like that :
Code: Select all
// clear current GUI
device->clearSystemMessages();
device->setEventReceiver(NULL);
const core::list<IGUIElement*>& children = env->getRootGUIElement()->getChildren();
while (!children.empty())
(*children.getLast())->remove();
// create new GUI
gui::IGUIContextMenu* menu = env->addMenu();
menu->addItem(L"File", -1, true, true);
...
add other GUI stuff
...
device->clearSystemMessages();
device->setEventReceiver(this->er);
Also, sometimes it doesn't throw any exception but the new created GUI is built partially only... This is very weird.
Has anyone an idea about how to solve this problem ?
Thanks in advance!