From: ehofman Date: Thu, 30 Jun 2005 19:10:18 +0000 (+0000) Subject: Restore the old behavior. Additions are likely. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=38e50840189756cacf2e306ed0c2a2db941e6123;p=simgear.git Restore the old behavior. Additions are likely. --- diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 6f8495c7..dd8cb0c0 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -778,7 +778,6 @@ SGPropertyNode::alias (SGPropertyNode * target) clearValue(); _value.alias = target; _type = ALIAS; - _value.alias->incrementRef(); return true; } @@ -802,7 +801,6 @@ SGPropertyNode::unalias () if (_type != ALIAS) return false; _type = NONE; - _value.alias->decrementRef(); _value.alias = 0; return true; } @@ -914,10 +912,10 @@ SGPropertyNode::getChildren (const char * name) const /** - * Detach a child node from the tree and return a guarded pointer to it. + * Remove a child node */ SGPropertyNode_ptr -SGPropertyNode::detachChild (const char * name, int index, bool keep) +SGPropertyNode::removeChild (const char * name, int index, bool keep) { SGPropertyNode_ptr ret; int pos = find_child(name, index, _children); @@ -940,64 +938,6 @@ SGPropertyNode::detachChild (const char * name, int index, bool keep) } -/** - * Remove a child node, and all children that aren't referenced. - * Returns "true" if the node and all subnodes could be removed. - */ -bool -SGPropertyNode::removeChild (const char * name, int index) -{ - int pos = find_child(name, index, _children); - if (pos >= 0) { - vector::iterator it = _children.begin(); - it += pos; - SGPropertyNode *node = _children[pos]; - if (node->_count != 1 || node->isTied() || !node->removeChildren()) - return false; - - if (_path_cache) - _path_cache->erase(name); // EMH - TODO: Take "index" into account! - - node->setAttribute(REMOVED, true); - node->clearValue(); - fireChildRemoved(node); - _children.erase(it); - } - return true; -} - - -/** - * Remove all children nodes, or all with a given name. - * Returns "true" if the node and all subnodes could be removed. - */ -bool -SGPropertyNode::removeChildren(const char *name) -{ - bool success = true; - vector::iterator it = _children.end(); - vector::iterator begin = _children.begin(); - while (it-- != begin) { - SGPropertyNode *node = *it; - if (name && !compare_strings(node->getName(), name)) - continue; - - if (node->_count != 1 || node->isTied() || !node->removeChildren()) - success = false; - else { - if (_path_cache) - _path_cache->erase(node->getName()); - - node->setAttribute(REMOVED, true); - node->clearValue(); - fireChildRemoved(node); - _children.erase(it); - } - } - return success; -} - - const char * SGPropertyNode::getDisplayName (bool simplify) const { diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index 092fc224..9ce7df4b 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -707,27 +707,12 @@ public: /** - * Detach a child node from the tree and return guarded pointr to it. + * Remove a child node */ - SGPropertyNode_ptr detachChild (const char * name, int index = 0, + SGPropertyNode_ptr removeChild (const char * name, int index = 0, bool keep = true); - /** - * Remove a child node. Returns "true" if the node and all subnodes could - * be removed, and "false" if at least one node had to remain, because it - * was tied, aliased, or refcounted through SGPropertyNode_ptr. - */ - bool removeChild (const char * name, int index = 0); - - - /** - * Remove all children nodes, or all with a given name. True if all nodes - * were removed. - */ - bool removeChildren(const char * name = 0); - - // // Alias support. //