diff --git a/simgear/structure/SGBinding.cxx b/simgear/structure/SGBinding.cxx index a96307cc..62d1b3c5 100644 --- a/simgear/structure/SGBinding.cxx +++ b/simgear/structure/SGBinding.cxx @@ -47,6 +47,14 @@ SGBinding::~SGBinding() _arg->getParent()->removeChild(_arg->getName(), _arg->getIndex(), false); } +void +SGBinding::clear() +{ + _command = NULL; + _arg.clear(); + _setting.clear(); +} + void SGBinding::read(const SGPropertyNode* node, SGPropertyNode* root) { @@ -149,3 +157,11 @@ SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNod return result; } + +void clearBindingList(const SGBindingList& aBindings) +{ + BOOST_FOREACH(SGBinding_ptr b, aBindings) { + b->clear(); + } +} + diff --git a/simgear/structure/SGBinding.hxx b/simgear/structure/SGBinding.hxx index 23e921c4..15757fae 100644 --- a/simgear/structure/SGBinding.hxx +++ b/simgear/structure/SGBinding.hxx @@ -58,6 +58,14 @@ public: */ virtual ~SGBinding (); + + /** + * 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. + */ + void clear(); + /** * Get the command name. @@ -154,4 +162,9 @@ void fireBindingListWithOffset(const SGBindingList& aBindings, double offset, do */ SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNode* aRoot); +/** + * call clear() on every binding in a list + */ +void clearBindingList(const SGBindingList& aBindings); + #endif