I'm trying to destroy all the buttons created for my main menu. The problem is that no matter how I do it I always get an error when I recreate the menu that the name of the destroyed button still exists.
What am I doing wrong here?
removing a child does not cause it to be destroyed, it basically unlinks it from the widget heirarchy. For example in Ogre you can create a SceneNode, then remove it from its parent. The SceneNode exists, however its no longer part of the scene. Likewise a detached button still exists, but is not part of the GUI. The only reason you'd want to detach widgets is to attach it to some other widget later on.
The reason I removeChild before I destroyWidget is because I get an error about it still having a parent
Widget it attached to another widget! in Sheet::destroyWidget
Your code says
Shouldn't it be
You could also try calling
Unfortunately I'm using the quickgui version that comes with Python-Ogre and there doesn't seem to be a destroy() method for widgets.
I believe I'll just keep the button for my menus in memory since they don't take up much ram compared to the game itself and just reuse them when needed.
Hm, I think you've uncovered a bug, and hopefully I've fixed it. When widgets are destroyed they weren't updating the Sheets name list, so when creating a new button with name X, the sheet thought a widget with name X still existed. While you're not using the latest version, I've fixed this in the latest. Thanks for bringing this up.