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:
Florent Rougon
2018-01-20 11:51:54 +01:00
parent 8621925e75
commit 40534d6316
2 changed files with 5 additions and 10 deletions

View File

@@ -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()
{

View File

@@ -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();