Remove overzealous, invasive behavior from SGBinding's destructor
Since the dawn of times (FG commit
1bcaf4bfdd38f18ac7c375dd9319935ff3df56ac, where SGBinding was called
FGBinding), SGBinding's destructor has had a strange behavior:
SGBinding::~SGBinding()
{
if(_arg && _arg->getParent())
_arg->getParent()->removeChild(_arg->getName(), _arg->getIndex());
}
In other words, it used to remove the passed-in <binding> node from its
parent node (if any) once the SGBinding instance got destroyed. This
behavior is very unintuitive to several people and has resulted in a few
workarounds in the FG code base just to cope with this strangeness.
This commit gives SGBinding the implictly-generated destructor,
therefore SGBinding::~SGBinding() does not attempt to remove the
property node anymore.
See disussion at:
https://sourceforge.net/p/flightgear/mailman/flightgear-devel/thread/87d12b1h0h.fsf%40frougon.crabdance.com/#msg36190666
This commit is contained in:
@@ -41,12 +41,6 @@ SGBinding::SGBinding(const SGPropertyNode* node, SGPropertyNode* root)
|
||||
read(node, root);
|
||||
}
|
||||
|
||||
SGBinding::~SGBinding()
|
||||
{
|
||||
if(_arg && _arg->getParent())
|
||||
_arg->getParent()->removeChild(_arg->getName(), _arg->getIndex());
|
||||
}
|
||||
|
||||
void
|
||||
SGBinding::clear()
|
||||
{
|
||||
|
||||
@@ -58,13 +58,14 @@ public:
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~SGBinding ();
|
||||
virtual ~SGBinding () = default;
|
||||
|
||||
|
||||
/**
|
||||
* clear internal state of the binding back to empty. This is useful
|
||||
* if you don't want the 'remove on delete' behaviour of the
|
||||
* destructor.
|
||||
* Clear internal state of the binding back to empty.
|
||||
*
|
||||
* This was particularly useful when SGBinding's destructor had its 'remove
|
||||
* on delete' behaviour, however this is not the case anymore.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user