]> git.mxchange.org Git - simgear.git/commitdiff
Another place to catch SG exceptions.
authorThorstenB <brehmt@gmail.com>
Thu, 20 Jan 2011 00:06:46 +0000 (01:06 +0100)
committerThorstenB <brehmt@gmail.com>
Thu, 20 Jan 2011 00:06:46 +0000 (01:06 +0100)
SGBinding::fire needs to catch, otherwise exceptions in the event handler
context cause an FG exit (fixes a crash with the route manager dialog).

simgear/structure/SGBinding.cxx

index 9e5fce06a5a3745a5e79dfa8b8b5bc2b5e42beaa..836d7abc1364201817df01803040deeb9437a566 100644 (file)
@@ -16,6 +16,8 @@
 
 #include <simgear/math/SGMath.hxx>
 
+#include <simgear/structure/exception.hxx>
+
 SGBinding::SGBinding()
   : _command(0),
     _arg(new SGPropertyNode),
@@ -62,9 +64,17 @@ SGBinding::fire () const
       _command = SGCommandMgr::instance()->getCommand(_command_name);
     if (_command == 0) {
       SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding");
-    } else if (!(*_command)(_arg)) {
-      SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command "
-             << _command_name);
+    } else
+    {
+        try {
+            if (!(*_command)(_arg)) {
+                  SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command "
+                         << _command_name);
+            }
+        } catch (sg_exception& e) {
+          SG_LOG(SG_GENERAL, SG_ALERT, "command '" << _command_name << "' failed with exception\n"
+            << "\tmessage:" << e.getMessage() << " (from " << e.getOrigin() << ")");
+        }
     }
   }
 }