From: timoore Date: Wed, 15 Jul 2009 23:08:10 +0000 (+0000) Subject: Don't cache results of getDisplayName X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=390eb1c6e906cb287d9e4f25b1737f4dc3679f8b;p=simgear.git Don't cache results of getDisplayName Return a std::string result instead of char *. --- diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 9db543b6..6d6c2ede 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -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; } diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index 8e3647ee..9bef6844 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -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;