]> git.mxchange.org Git - flightgear.git/commitdiff
Work-around for bug #222 - delete the units/WOW property on init.
authorJames Turner <zakalawe@mac.com>
Fri, 31 Dec 2010 18:26:23 +0000 (18:26 +0000)
committerJames Turner <zakalawe@mac.com>
Sat, 1 Jan 2011 16:08:06 +0000 (16:08 +0000)
Another cleanup

src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/JSBSim.hxx

index 15b575123be9880825023b398b3a4e1a8bf68112..d92d265f0628c8b5dece5d58cc9d2c6c10963748 100644 (file)
@@ -143,6 +143,8 @@ FGJSBsim::FGJSBsim( double dt )
             break;
         }
     }
+    
+    resetPropertyState();
 
     fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
 
@@ -298,13 +300,6 @@ FGJSBsim::FGJSBsim( double dt )
 FGJSBsim::~FGJSBsim(void)
 {
   delete fdmex;
-  
-  SGPropertyNode_ptr jsbsimRoot = fgGetNode("/fdm/jsbsim");
-  if (jsbsimRoot) {
-    SGPropertyNode* fdm = jsbsimRoot->getParent();
-    fdm->removeChild("jsbsim", 0, false);
-  }
-  // properties are deleted when the sharedPtr above goes away
 }
 
 /******************************************************************************/
@@ -1418,3 +1413,22 @@ void FGJSBsim::update_external_forces(double t_off)
     fgSetDouble("/fdm/jsbsim/systems/hook/tailhook-pos-deg", fi);
 }
 
+
+void FGJSBsim::resetPropertyState()
+{
+// this code works-around bug #222:
+// http://code.google.com/p/flightgear-bugs/issues/detail?id=222
+// for whatever reason, having an existing value for the WOW
+// property causes the NaNs. Should that be fixed, this code can die
+  SGPropertyNode* gear = fgGetNode("/fdm/jsbsim/gear", false);
+  if (!gear) {
+    return;
+  }
+  
+  int index = 0;
+  SGPropertyNode* unitNode = NULL;
+  for (; (unitNode = gear->getChild("unit", index)) != NULL; ++index) {
+    unitNode->removeChild("WOW", 0, false);
+  }
+}
+
index 6729a141ffc5f38d5f719b257d44a3fa9a5846be..1a80371677d69ec2927a9f8d63bed724244060e9 100644 (file)
@@ -284,6 +284,7 @@ private:
 
     void update_external_forces(double t_off);
 
+    void resetPropertyState();
 };