- modified to use pointers to bindings to avoid copying
This commit is contained in:
parent
26bfe067e9
commit
79b25c850e
3 changed files with 11 additions and 7 deletions
|
@ -450,6 +450,8 @@ FGPanelAction::FGPanelAction ()
|
|||
FGPanelAction::FGPanelAction (int button, int x, int y, int w, int h)
|
||||
: _button(button), _x(x), _y(y), _w(w), _h(h)
|
||||
{
|
||||
for (unsigned int i = 0; i < _bindings.size(); i++)
|
||||
delete _bindings[i];
|
||||
}
|
||||
|
||||
FGPanelAction::~FGPanelAction ()
|
||||
|
@ -457,7 +459,7 @@ FGPanelAction::~FGPanelAction ()
|
|||
}
|
||||
|
||||
void
|
||||
FGPanelAction::addBinding (const FGBinding &binding)
|
||||
FGPanelAction::addBinding (FGBinding * binding)
|
||||
{
|
||||
_bindings.push_back(binding);
|
||||
}
|
||||
|
@ -468,7 +470,7 @@ FGPanelAction::doAction ()
|
|||
if (test()) {
|
||||
int nBindings = _bindings.size();
|
||||
for (int i = 0; i < nBindings; i++) {
|
||||
_bindings[i].fire();
|
||||
_bindings[i]->fire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -714,7 +716,7 @@ FGGroupLayer::FGGroupLayer ()
|
|||
|
||||
FGGroupLayer::~FGGroupLayer ()
|
||||
{
|
||||
for (int i = 0; i < _layers.size(); i++)
|
||||
for (unsigned int i = 0; i < _layers.size(); i++)
|
||||
delete _layers[i];
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,9 @@ public:
|
|||
virtual int getHeight () const { return _h; }
|
||||
|
||||
// Setters.
|
||||
virtual void addBinding (const FGBinding &binding);
|
||||
|
||||
// transfer pointer ownership
|
||||
virtual void addBinding (FGBinding * binding);
|
||||
virtual void setButton (int button) { _button = button; }
|
||||
virtual void setX (int x) { _x = x; }
|
||||
virtual void setY (int y) { _y = y; }
|
||||
|
@ -249,7 +251,7 @@ public:
|
|||
virtual void doAction ();
|
||||
|
||||
private:
|
||||
typedef vector<FGBinding> binding_list_t;
|
||||
typedef vector<FGBinding *> binding_list_t;
|
||||
|
||||
int _button;
|
||||
int _x;
|
||||
|
|
|
@ -242,10 +242,10 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
|
|||
FGPanelAction * action = new FGPanelAction(button, x, y, w, h);
|
||||
|
||||
vector<const SGPropertyNode *>bindings = node->getChildren("binding");
|
||||
for (int i = 0; i < bindings.size(); i++) {
|
||||
for (unsigned int i = 0; i < bindings.size(); i++) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
|
||||
<< bindings[i]->getStringValue("command"));
|
||||
action->addBinding(FGBinding(bindings[i])); // TODO: allow modifiers
|
||||
action->addBinding(new FGBinding(bindings[i])); // TODO: allow modifiers
|
||||
}
|
||||
|
||||
readConditions(action, node);
|
||||
|
|
Loading…
Reference in a new issue