From 390eb1c6e906cb287d9e4f25b1737f4dc3679f8b Mon Sep 17 00:00:00 2001 From: timoore Date: Wed, 15 Jul 2009 23:08:10 +0000 Subject: [PATCH] Don't cache results of getDisplayName Return a std::string result instead of char *. --- simgear/props/props.cxx | 8 ++++---- simgear/props/props.hxx | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) 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; -- 2.39.5