- delete bindings in the *destructor* (must have been an editing accident)
- 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?)
This commit is contained in:
parent
1bcaf4bfdd
commit
ee7b882dd9
2 changed files with 26 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -182,18 +182,33 @@ 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);
|
||||
|
||||
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);
|
||||
j = 0;
|
||||
while (dest->getChild("binding", j))
|
||||
j++;
|
||||
|
||||
binding = dest->getChild("binding", j, true);
|
||||
copyProperties(bindings[i], binding);
|
||||
action->addBinding(new FGBinding(binding), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue