]> git.mxchange.org Git - flightgear.git/commitdiff
Do late, lazy binding of commands from the command manager.
authordavid <david>
Sat, 18 Jan 2003 16:25:50 +0000 (16:25 +0000)
committerdavid <david>
Sat, 18 Jan 2003 16:25:50 +0000 (16:25 +0000)
src/Input/input.cxx
src/Input/input.hxx

index 7a5cbaedc8c90f1fa882fe11ad9b986472337eef..5bc5132dc38fcb25d01495b0c5fcd8df1c652a10 100644 (file)
@@ -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)) {
index 1111be944e31693421b67abc336b97d331e920dc..6730a3689a559c66d68a92288491eecb007f2de9 100644 (file)
@@ -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;
 };