From c9051cedcad32a479911c0a9a9c0201f207882ce Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Sat, 29 May 2021 22:59:34 +0100 Subject: [PATCH] simgear/props/props.cxx: fixed bug in SGPropertyNode::removeChild(). Don't set node->_parent to null before calling SGPropertyNodeImpl::fireChildRemoved(). This fixes problem with Jaguar-GR1 HUD. [Should probably set node->_parent to null before returning, but previous (non-locked) code didn't do this, and it would require acquiring mutex. --- simgear/props/props.cxx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 32b6ec26..7ccacdbd 100755 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -2621,11 +2621,6 @@ bool SGPropertyNode::removeChild(SGPropertyNode* node) SGPropertyLockExclusive exclusive(*this); SGPropertyLockExclusive exclusive_node(*node); - /*SGSharedPtr p = node->_parent.lock(); - if (p != this) { - assert(0); - return false; - }*/ if (node->_parent != this) { assert(0); return false; @@ -2637,8 +2632,6 @@ bool SGPropertyNode::removeChild(SGPropertyNode* node) } SGPropertyNodeImpl::setAttribute(exclusive_node, *node, REMOVED, true); SGPropertyNodeImpl::clearValue(exclusive_node, *node); - node->_parent = nullptr; - exclusive_node.release(); SGPropertyNodeImpl::fireChildRemoved(exclusive, *this, this /*parent*/, node); @@ -2646,6 +2639,9 @@ bool SGPropertyNode::removeChild(SGPropertyNode* node) // released our exclusive lock. it = std::find(_children.begin(), _children.end(), node); _children.erase(it); + + // fixme: should probably set node->_parent to null here. this was not done + // in previous (non-locking) props code. return true; }