Don't cache results of getDisplayName
Return a std::string result instead of char *.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user