Page 1 of 1

TabControl

Posted: Mon Oct 18, 2004 15:05
by zola
Hi
If I remove a tab then add it again the windowmanager throws an AlreadyExistsException, even though i destroy the tabwindow.

Code: Select all

CEGUI::Window* defaultwin=CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow",(CEGUI::utf8*)"Test1");

tabCtrl->addTab(defaultwin);

....

tabCtrl->removeTab(defaultwin);
CEGUI::WindowManager::getSingleton().destroyWindow(defaultwin);
...

CEGUI::Window* defaultwin2=CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow",(CEGUI::utf8*)"Test1");

tabCtrl->addTab(defaultwin2); // error thrown


I recon this has something to do with the TabButton (error log: Exception: WindowManager::createWindow - A Window object with the name 'btnTest1' already exists within the system. ) but I haven't been able to resolve the problem. I tried destroying the button in TabControl::removeButtonForTabContent but this turned out to be the wrong place :)

Maybe I'm doing something wrong with deleting the tab? Any hints where I should look?

Cheers
Tom

TabControl

Posted: Mon Oct 18, 2004 15:31
by CrazyEddie
This is a bug :shock:

I'll fix it and post back in a little while when I've done it :)

TabControl

Posted: Mon Oct 18, 2004 15:45
by CrazyEddie
This is now fixed in CVS.

Here, have a patch ;)

Code: Select all

Index: src/elements/CEGUITabControl.cpp
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/src/elements/CEGUITabControl.cpp,v
retrieving revision 1.4
diff -u -r1.4 CEGUITabControl.cpp
--- src/elements/CEGUITabControl.cpp   16 Oct 2004 16:35:47 -0000   1.4
+++ src/elements/CEGUITabControl.cpp   18 Oct 2004 15:36:55 -0000
@@ -380,6 +380,8 @@
     // remove
     d_tabButtonIndexMap.erase(tb->getTabIndex());
     d_tabButtonPane->removeChildWindow(tb);
+   // destroy
+   WindowManager::getSingleton().destroyWindow(tb);
 }
 /*************************************************************************
 Remove tab button