]> git.mxchange.org Git - flightgear.git/commitdiff
- delete bindings in the *destructor* (must have been an editing accident)
authormfranz <mfranz>
Mon, 20 Jun 2005 18:52:54 +0000 (18:52 +0000)
committermfranz <mfranz>
Mon, 20 Jun 2005 18:52:54 +0000 (18:52 +0000)
- create copies of bindings in /sim/bindings/, because FGBindings doesn't
  do that any more  (is there a better way to find the first free child?)

src/Cockpit/panel.cxx
src/Cockpit/panel_io.cxx

index 4134c196cfa91f498c134949798c357a7ac19d83..cc0785c9347d72f8944922b8a6832d296bf01026 100644 (file)
@@ -598,14 +598,14 @@ FGPanelAction::FGPanelAction (int button, int x, int y, int w, int h,
                               bool repeatable)
     : _button(button), _x(x), _y(y), _w(w), _h(h), _repeatable(repeatable)
 {
-  for (unsigned int i = 0; i < 2; i++) {
-      for (unsigned int j = 0; j < _bindings[i].size(); j++)
-          delete _bindings[i][j];
-  }
 }
 
 FGPanelAction::~FGPanelAction ()
 {
+  for (unsigned int i = 0; i < 2; i++) {
+      for (unsigned int j = 0; j < _bindings[i].size(); j++)
+          delete _bindings[i][j];
+  }
 }
 
 void
index 64641b5f74c8f4db7aa569848e63216fe1644f74..b4185ddbb291cbe53c5f70deae6ffc74a40fb5f9 100644 (file)
@@ -182,19 +182,34 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
   FGPanelAction * action = new FGPanelAction(button, x, y, w, h, repeatable);
 
   vector<SGPropertyNode_ptr>bindings = node->getChildren("binding");
+  SGPropertyNode * dest = fgGetNode("/sim/bindings", true);
 
-  unsigned int i;
+  SGPropertyNode *binding;
+  unsigned int i, j;
   for (i = 0; i < bindings.size(); i++) {
     SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
-          << bindings[i]->getStringValue("command"));
-    action->addBinding(new FGBinding(bindings[i]), 0);
+      << bindings[i]->getStringValue("command"));
+
+    j = 0;
+    while (dest->getChild("binding", j))
+      j++;
+
+    binding = dest->getChild("binding", j, true);
+    copyProperties(bindings[i], binding);
+    action->addBinding(new FGBinding(binding), 0);
   }
 
   if (node->hasChild("mod-up")) {
-      bindings = node->getChild("mod-up")->getChildren("binding");
-      for (i = 0; i < bindings.size(); i++) {
-          action->addBinding(new FGBinding(bindings[i]), 1);
-      }
+    bindings = node->getChild("mod-up")->getChildren("binding");
+    for (i = 0; i < bindings.size(); i++) {
+      j = 0;
+      while (dest->getChild("binding", j))
+        j++;
+
+      binding = dest->getChild("binding", j, true);
+      copyProperties(bindings[i], binding);
+      action->addBinding(new FGBinding(binding), 1);
+    }
   }
 
   readConditions(action, node);