Don't cache results of getDisplayName

Return a std::string result instead of char *.
This commit is contained in:
timoore
2009-07-15 23:08:10 +00:00
committed by Tim Moore
parent d4c6530a72
commit 390eb1c6e9
2 changed files with 5 additions and 7 deletions

View File

@@ -994,16 +994,16 @@ SGPropertyNode::remove_linked_node (hash_table * node)
}
const char *
string
SGPropertyNode::getDisplayName (bool simplify) const
{
_display_name = _name;
string display_name = _name;
if (_index != 0 || !simplify) {
stringstream sstr;
sstr << '[' << _index << ']';
_display_name += sstr.str();
display_name += sstr.str();
}
return _display_name.c_str();
return display_name;
}

View File

@@ -795,11 +795,10 @@ public:
*/
const char * getName () const { return _name.c_str(); }
/**
* Get the node's pretty display name, with subscript when needed.
*/
const char * getDisplayName (bool simplify = false) const;
std::string getDisplayName (bool simplify = false) const;
/**
@@ -1642,7 +1641,6 @@ private:
int _index;
std::string _name;
mutable std::string _display_name;
/// To avoid cyclic reference counting loops this shall not be a reference
/// counted pointer
SGPropertyNode * _parent;