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.
This commit is contained in:
James Turner 2014-01-15 21:56:16 +00:00
parent 0428adff03
commit 7184828a58
2 changed files with 29 additions and 0 deletions

View File

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

View File

@ -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