From: david Date: Sat, 18 Jan 2003 16:25:50 +0000 (+0000) Subject: Do late, lazy binding of commands from the command manager. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9e2707c9f8f6262d4d40fce4ac0acfe54fef8757;p=flightgear.git Do late, lazy binding of commands from the command manager. --- diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 7a5cbaedc..5bc5132dc 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -113,13 +113,6 @@ FGBinding::read (const SGPropertyNode * node) return; } - _command = globals->get_commands()->getCommand(_command_name); - if (_command == 0) { - SG_LOG(SG_INPUT, SG_ALERT, "Command " << _command_name << " is undefined"); - _arg = 0; - return; - } - delete _arg; _arg = new SGPropertyNode; _setting = 0; @@ -130,6 +123,8 @@ void FGBinding::fire () const { if (test()) { + if (_command == 0) + _command = globals->get_commands()->getCommand(_command_name); if (_command == 0) { SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding"); } else if (!(*_command)(_arg)) { diff --git a/src/Input/input.hxx b/src/Input/input.hxx index 1111be944..6730a3689 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -145,9 +145,8 @@ private: // just to be safe. FGBinding (const FGBinding &binding); - string _command_name; - SGCommandMgr::command_t _command; + mutable SGCommandMgr::command_t _command; mutable SGPropertyNode * _arg; mutable SGPropertyNode_ptr _setting; };