]> git.mxchange.org Git - simgear.git/commitdiff
Support a 'clear' operation on SGBinding.
authorJames Turner <zakalawe@mac.com>
Wed, 15 Jan 2014 21:56:16 +0000 (21:56 +0000)
committerJames Turner <zakalawe@mac.com>
Wed, 15 Jan 2014 21:56:26 +0000 (21:56 +0000)
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.

simgear/structure/SGBinding.cxx
simgear/structure/SGBinding.hxx

index a96307cc9f6cced777102024674b1e665f947c3c..62d1b3c5d96c1c5eafdad0b2a00422838d8d3dfe 100644 (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();
+    }
+}
+
index 23e921c461d75989e9579b121c121b789d4dd6db..15757faeeeb357c214c0dd3c5d0a06abe74d5a46 100644 (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