]> git.mxchange.org Git - flightgear.git/commitdiff
fix bug #177: crash caused by route manager/gps/navradio
authorThorstenB <brehmt@gmail.com>
Sun, 5 Dec 2010 19:35:21 +0000 (20:35 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 5 Dec 2010 19:35:21 +0000 (20:35 +0100)
Uninitialized variables were sources for NaN values.
Once NaNs are passed to Nasal (through (tied) properties), these cause
a crash. Nasal cannot handle NaNs - it interprets these as pointer values...

src/Instrumentation/navradio.cxx
src/Instrumentation/navradio.hxx
src/Instrumentation/rnav_waypt_controller.cxx
src/Instrumentation/rnav_waypt_controller.hxx

index 2aac4b26d1cc4fbdd2c0db4a64c9544f110c2bca..143951694cf93a66045c77faf996ddcd791ba9fb 100644 (file)
@@ -92,12 +92,19 @@ SGPropertyNode_ptr createServiceableProp(SGPropertyNode* aParent, const char* aN
 
 // Constructor
 FGNavRadio::FGNavRadio(SGPropertyNode *node) :
+    term_tbl(NULL),
+    low_tbl(NULL),
+    high_tbl(NULL),
     lon_node(fgGetNode("/position/longitude-deg", true)),
     lat_node(fgGetNode("/position/latitude-deg", true)),
     alt_node(fgGetNode("/position/altitude-ft", true)),
+    _operable(false),
     play_count(0),
     last_time(0),
     target_radial(0.0),
+    effective_range(0.0),
+    target_gs(0.0),
+    twist(0.0),
     horiz_vel(0.0),
     last_x(0.0),
     last_loc_dist(0.0),
@@ -107,6 +114,16 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
     _name(node->getStringValue("name", "nav")),
     _num(node->getIntValue("number", 0)),
     _time_before_search_sec(-1.0),
+    _gsCart(SGVec3d::zeros()),
+    _gsAxis(SGVec3d::zeros()),
+    _gsVertical(SGVec3d::zeros()),
+    _dmeInRange(false),
+    _toFlag(false),
+    _fromFlag(false),
+    _cdiDeflection(0.0),
+    _cdiCrossTrackErrorM(0.0),
+    _gsNeedleDeflection(0.0),
+    _gsNeedleDeflectionNorm(0.0),
     _sgr(NULL)
 {
     SGPath path( globals->get_fg_root() );
@@ -120,8 +137,7 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
     term_tbl = new SGInterpTable( term.str() );
     low_tbl = new SGInterpTable( low.str() );
     high_tbl = new SGInterpTable( high.str() );
-    
-    
+
     string branch("/instrumentation/" + _name);
     _radio_node = fgGetNode(branch.c_str(), _num, true);
 }
index f272f6700419e77d9bc28caba378be590eb3e408..a8451a6496d453333cdac004d90da50c1e849ffd 100644 (file)
@@ -137,8 +137,6 @@ class FGNavRadio : public SGSubsystem, public SGPropertyChangeListener
     string dme_fx_name;
 
     double target_radial;
-    SGTimeStamp prev_time;
-    SGTimeStamp curr_time;
     double effective_range;
     double target_gs;
     double twist;
index 977452e1806deb8a255e5b6c6f376ab89430e4af..09ac2b81274c908c1557e76dc18d594fca4aee0b 100644 (file)
@@ -69,8 +69,8 @@ bool geocRadialIntersection(const SGGeoc& a, double r1, const SGGeoc& b, double
   double crs12 = SGGeodesy::courseRad(a, b),
     crs21 = SGGeodesy::courseRad(b, a);
     
-  double degCrs12 = crs12 * SG_RADIANS_TO_DEGREES;
-  double degCrs21 = crs21 * SG_RADIANS_TO_DEGREES;
+  //double degCrs12 = crs12 * SG_RADIANS_TO_DEGREES;
+  //double degCrs21 = crs21 * SG_RADIANS_TO_DEGREES;
     
  /* 
   if (sin(diffLon) < 0.0) {
@@ -157,7 +157,9 @@ class BasicWayptCtl : public WayptController
 {
 public:
   BasicWayptCtl(RNAV* aRNAV, const WayptRef& aWpt) :
-    WayptController(aRNAV, aWpt)
+    WayptController(aRNAV, aWpt),
+    _distanceM(0.0),
+    _courseDev(0.0)
   {
     if (aWpt->flag(WPT_DYNAMIC)) {
       throw sg_exception("BasicWayptCtrl doesn't work with dynamic waypoints");
@@ -226,7 +228,10 @@ class RunwayCtl : public WayptController
 {
 public:
   RunwayCtl(RNAV* aRNAV, const WayptRef& aWpt) :
-    WayptController(aRNAV, aWpt)
+    WayptController(aRNAV, aWpt),
+    _runway(NULL),
+    _distanceM(0.0),
+    _courseDev(0.0)
   {
   }
   
@@ -365,8 +370,8 @@ class InterceptCtl : public WayptController
 {
 public:
   InterceptCtl(RNAV* aRNAV, const WayptRef& aWpt) :
-    WayptController(aRNAV, aWpt)
-    
+    WayptController(aRNAV, aWpt),
+    _trueRadial(0.0)
   {
     if (_waypt->type() != "radialIntercept") {
       throw sg_exception("invalid waypoint type", "InterceptCtl ctor");
@@ -412,8 +417,9 @@ class DMEInterceptCtl : public WayptController
 {
 public:
   DMEInterceptCtl(RNAV* aRNAV, const WayptRef& aWpt) :
-    WayptController(aRNAV, aWpt)
-    
+    WayptController(aRNAV, aWpt),
+    _dme(NULL),
+    _distanceNm(0.0)
   {
     if (_waypt->type() != "dmeIntercept") {
       throw sg_exception("invalid waypoint type", "DMEInterceptCtl ctor");
@@ -546,7 +552,9 @@ private:
 
 DirectToController::DirectToController(RNAV* aRNAV, const WayptRef& aWpt, const SGGeod& aOrigin) :
   WayptController(aRNAV, aWpt),
-  _origin(aOrigin)
+  _origin(aOrigin),
+  _distanceM(0.0),
+  _courseDev(0.0)
 {
 }
 
@@ -600,7 +608,9 @@ SGGeod DirectToController::position() const
 ///////////////////////////////////////////////////////////////////////////////
 
 OBSController::OBSController(RNAV* aRNAV, const WayptRef& aWpt) :
-  WayptController(aRNAV, aWpt)
+  WayptController(aRNAV, aWpt),
+  _distanceM(0.0),
+  _courseDev(0.0)
 {
 }
 
index 4d99c8af77f14754f71000aaefd2a4cfd2fc6dcd..b5c4b19e1b5c3c242bb23d41681a42046cdf636e 100644 (file)
@@ -129,6 +129,7 @@ public:
 protected:
   WayptController(RNAV* aRNAV, const WayptRef& aWpt) :
     _waypt(aWpt),
+    _targetTrack(0),
     _rnav(aRNAV),
     _isDone(false)
   { }