Page 1 of 1

AlreadyExistsException when calling loadWindowLayout()?

Posted: Tue Mar 13, 2007 23:41
by some_name
I've worked around my HandleClicked() problem by deferreing deletion of the window layout until the event injection has returned.

However, now I have a problem when showing a GUI for the second time. The flow control is something like:

window = WindowManager::getSingleton().loadWindowLayout(name);
guiSystem->setGUISheet(window);
delete window;
guiSystem->setGUISheet(NULL);
window = WindowManager::getSingleton().loadWindowLayout(name);

Obviously, this is not all in one function; there's time between the calls.

When getting to the second load call (which attempts to open a new copy of the previously deleted window), I get an AlreadyExistsException thrown from within the library. I use the SDK library installer, not built myself.

Apparently, the GUI system is holding on to some concept of the previously window/layout, even though I've deleted it and un-configured it from the GUI system -- I draw the conclusion that I need to do something more to clean up the loaded GUI before attempting to re-load it.

The documentation for loadWindowLayout() doesn't mention this exception at all; nor does the destructor for Window say anything about special cleanup requirements. The description for setGUISheet() is similarly unhelpful. What am I doing wrong?

Posted: Wed Mar 14, 2007 08:49
by scriptkid
Hi there,

you should not delete windows with 'delete' but rather by calling WindowManager::getSingleton().destroyWindow(window->getName()) for them.

HTH :)

Posted: Wed Mar 14, 2007 23:54
by some_name
You know, it would help if the documentation for the window class actually said that. It would help even more if the destructor for the window class was protected in that case.
But thanks for the info that the documentation lacked!