X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fprops%2Fprops.cxx;h=3d63758e143707fe38b100728e8ac6f7534f2e99;hb=1cda1fc201cb48d8a265eee011d608f34e5a0618;hp=b0cda2d3f7321bb409453081edfbf3e2764e2bb4;hpb=64072be83c76864beb946671e7110cf6a235f41f;p=simgear.git diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index b0cda2d3..3d63758e 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -1036,17 +1036,22 @@ SGPropertyNode::getDisplayName (bool simplify) const } -const char * +string SGPropertyNode::getPath (bool simplify) const { - // Calculate the complete path only once. - if (_parent != 0 && _path.empty()) { - _path = _parent->getPath(simplify); - _path += '/'; - _path += getDisplayName(simplify); + typedef std::vector PList; + PList pathList; + for (const SGPropertyNode* node = this; node->_parent; node = node->_parent) + pathList.push_back(node); + string result; + for (PList::reverse_iterator itr = pathList.rbegin(), + rend = pathList.rend(); + itr != rend; + ++itr) { + result += '/'; + result += (*itr)->getDisplayName(simplify); } - - return _path.c_str(); + return result; } props::Type