From a55c939c5ee8f64aedf11ebaa38a49da7a71c3c4 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 11 Dec 2015 12:49:32 -0600 Subject: [PATCH] Fix a JSBSim crash on OSG-quit (i.e Cmd-Q / window closing, not the normal FlightGear quit sequence) --- src/AIModel/AIBase.cxx | 4 +++- src/FDM/JSBSim/JSBSim.cxx | 4 ++-- src/FDM/JSBSim/JSBSim.hxx | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 51146e077..339de5f27 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -235,7 +235,9 @@ FGAIBase::removeModel() } else { - SG_LOG(SG_AI, SG_ALERT, "AIBase: Could not unload model. Missing scenery manager!"); + aip.clear(); + _model = 0; + _modeldata = 0; } } diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index dbce5df72..0ac6cfb28 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -229,6 +229,8 @@ FGJSBsim::FGJSBsim( double dt ) fgGetNode("/fdm/jsbsim/sim-time-sec", true)->alias( node ); // end of sim-time-sec deprecation patch + terrain = fgGetNode("/sim/fdm/surface", true); + fdmex->Setdt( dt ); result = fdmex->LoadModel( aircraft_path.str(), @@ -1352,8 +1354,6 @@ FGJSBsim::get_agl_ft(double t, const double pt[3], double alt_off, SGQuatd hlToEc = SGQuatd::fromLonLat(geodPt); *agl = dot(hlToEc.rotate(SGVec3d(0, 0, 1)), SGVec3d(contact) - SGVec3d(pt)); - static SGPropertyNode_ptr terrain = fgGetNode("/sim/fdm/surface", true); - #ifdef JSBSIM_USE_GROUNDREACTIONS bool terrain_active = (terrain->getIntValue("override-level", -1) > 0) ? false : true; terrain->setBoolValue("active", terrain_active); diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx index accce2386..d6c3c6ab9 100644 --- a/src/FDM/JSBSim/JSBSim.hxx +++ b/src/FDM/JSBSim/JSBSim.hxx @@ -288,6 +288,8 @@ private: SGPropertyNode_ptr slaved; + SGPropertyNode_ptr terrain; + static std::map TURBULENCE_TYPE_NAMES; double last_hook_tip[3]; -- 2.39.5