Use SGPropertyNode_ptr and add a private copy constructor, both for
safety's sake.
This commit is contained in:
parent
0111183153
commit
5c2fb92a92
2 changed files with 9 additions and 14 deletions
|
@ -89,27 +89,21 @@ FGBinding::FGBinding ()
|
||||||
}
|
}
|
||||||
|
|
||||||
FGBinding::FGBinding (const SGPropertyNode * node)
|
FGBinding::FGBinding (const SGPropertyNode * node)
|
||||||
: _command(0),
|
|
||||||
_arg(new SGPropertyNode),
|
|
||||||
_setting(0)
|
|
||||||
{
|
{
|
||||||
|
FGBinding();
|
||||||
read(node);
|
read(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
FGBinding::~FGBinding ()
|
FGBinding::~FGBinding ()
|
||||||
{
|
{
|
||||||
// delete _arg; // Delete the saved arguments
|
|
||||||
// delete _command_state; // Delete the saved command state
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGBinding::read (const SGPropertyNode * node)
|
FGBinding::read (const SGPropertyNode * node)
|
||||||
{
|
{
|
||||||
const SGPropertyNode * conditionNode = node->getChild("condition");
|
const SGPropertyNode * conditionNode = node->getChild("condition");
|
||||||
if (conditionNode != 0) {
|
if (conditionNode != 0)
|
||||||
cerr << "Adding condition to binding" << endl;
|
|
||||||
setCondition(fgReadCondition(conditionNode));
|
setCondition(fgReadCondition(conditionNode));
|
||||||
}
|
|
||||||
|
|
||||||
_command_name = node->getStringValue("command", "");
|
_command_name = node->getStringValue("command", "");
|
||||||
if (_command_name.empty()) {
|
if (_command_name.empty()) {
|
||||||
|
@ -125,10 +119,7 @@ FGBinding::read (const SGPropertyNode * node)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete _arg;
|
_arg = (SGPropertyNode *)node;
|
||||||
_arg = new SGPropertyNode;
|
|
||||||
_setting = 0;
|
|
||||||
copyProperties(node, _arg); // FIXME: don't use whole node!!!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -139,10 +139,14 @@ public:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// just to be safe.
|
||||||
|
FGBinding (const FGBinding &binding);
|
||||||
|
|
||||||
|
|
||||||
string _command_name;
|
string _command_name;
|
||||||
SGCommandMgr::command_t _command;
|
SGCommandMgr::command_t _command;
|
||||||
mutable SGPropertyNode * _arg;
|
mutable SGPropertyNode_ptr _arg;
|
||||||
mutable SGPropertyNode * _setting;
|
mutable SGPropertyNode_ptr _setting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue