Kali
10-04-2008 20:53:46
QuickGUIWidget.cpp:76
- TextBox* newTextBox = dynamic_cast<TextBox*>(_createChild(mInstanceName+".ChildTextBox" + Ogre::StringConverter::toString(mItems.size()),TYP$
+ TextBox* newTextBox = dynamic_cast<TextBox*>(_createChild(generateName(TYPE_TEXTBOX), TYPE_TEXTBOX));
The problem with the original code is that mItems.size() does not guarantee a unique name.
Supose you have a max of 30 lines, when you fill up the console (add line31) nr1 is dropped, the size is decreased a second nr30 is generated which results in a trap.
And I was thinking, generateName is quite inneficiënt since it will always try to guess the same name first. This function could definitely benefit from a random generated name or better yet no name at all, that would make the name Lookup for the widgets you do provide a name for faster aswell. I'd say put the widget with a name in the front of the childwidgets array and those without a name at the back and stop a name lookup when you find a widget without a name.
Do you want this ?
- TextBox* newTextBox = dynamic_cast<TextBox*>(_createChild(mInstanceName+".ChildTextBox" + Ogre::StringConverter::toString(mItems.size()),TYP$
+ TextBox* newTextBox = dynamic_cast<TextBox*>(_createChild(generateName(TYPE_TEXTBOX), TYPE_TEXTBOX));
The problem with the original code is that mItems.size() does not guarantee a unique name.
Supose you have a max of 30 lines, when you fill up the console (add line31) nr1 is dropped, the size is decreased a second nr30 is generated which results in a trap.
And I was thinking, generateName is quite inneficiënt since it will always try to guess the same name first. This function could definitely benefit from a random generated name or better yet no name at all, that would make the name Lookup for the widgets you do provide a name for faster aswell. I'd say put the widget with a name in the front of the childwidgets array and those without a name at the back and stop a name lookup when you find a widget without a name.
Do you want this ?