From: James Turner Date: Wed, 15 Jan 2014 21:56:16 +0000 (+0000) Subject: Support a 'clear' operation on SGBinding. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7184828a5885d8335e67364dadc0b43bd57baa5e;p=simgear.git Support a 'clear' operation on SGBinding. Needed to bug-fix a problem with the menubar on Mac - post-3.0 I will change the behaviour of SGBinding's destructor to avoid the property copies in other use-cases. --- 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