X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fprops%2Fprops.cxx;h=dd8cb0c01fea7436eb50bf4be6bff8d733f0f48d;hb=68eb7031e2dce999d112d0164fa28d4b8d66922e;hp=7c004b5a69ea60e0d23035918cd577f4f045a936;hpb=24f908d9be3b6db5fe56e0071917ae9a42df3d46;p=simgear.git diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 7c004b5a..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,69 +912,29 @@ SGPropertyNode::getChildren (const char * name) const /** - * Remove a child node, and all children that aren't referenced. - * "keep" does only apply to the outmost item. Returns "true" if - * not all nodes could be removed. + * Remove a child node */ -bool +SGPropertyNode_ptr SGPropertyNode::removeChild (const char * name, int index, bool keep) { - bool dirty = false; + SGPropertyNode_ptr ret; int pos = find_child(name, index, _children); if (pos >= 0) { vector::iterator it = _children.begin(); it += pos; - SGPropertyNode *node = _children[pos]; - if (node->nChildren() && node->removeChildren()) - dirty = true; - - if (node->_count == 1 && !node->nChildren()) { - if (keep) - _removedChildren.push_back(node); - - 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 dirty; -} - -/** - * Remove all children nodes, or all with a given name. Returns - * "true" if not all nodes could be removed. - */ -bool -SGPropertyNode::removeChildren(const char *name) -{ - bool dirty = false; - 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->nChildren() && node->removeChildren()) - dirty = true; - - if (node->isTied() || node->_count != 1 || node->nChildren()) - dirty = true; - else { - if (_path_cache) - _path_cache->erase(node->getName()); - - node->setAttribute(REMOVED, true); - node->clearValue(); - fireChildRemoved(node); - _children.erase(it); + SGPropertyNode_ptr node = _children[pos]; + _children.erase(it); + if (keep) { + _removedChildren.push_back(node); } - } - return dirty; + if (_path_cache) + _path_cache->erase(name); // EMH - TODO: Take "index" into account! + node->setAttribute(REMOVED, true); + node->clearValue(); + ret = node; + fireChildRemoved(node); + } + return ret; }