From 40534d6316f3468c305c341210656b66ea309a68 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Sat, 20 Jan 2018 11:51:54 +0100 Subject: [PATCH] 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 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 --- simgear/structure/SGBinding.cxx | 6 ------ simgear/structure/SGBinding.hxx | 9 +++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/simgear/structure/SGBinding.cxx b/simgear/structure/SGBinding.cxx index 320e13a1..1f87ca95 100644 --- a/simgear/structure/SGBinding.cxx +++ b/simgear/structure/SGBinding.cxx @@ -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() { diff --git a/simgear/structure/SGBinding.hxx b/simgear/structure/SGBinding.hxx index 3574a524..ed3a951c 100644 --- a/simgear/structure/SGBinding.hxx +++ b/simgear/structure/SGBinding.hxx @@ -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();