]> git.mxchange.org Git - flightgear.git/commitdiff
Reset: change FDM ownership
authorJames Turner <zakalawe@mac.com>
Sun, 1 Dec 2013 21:34:30 +0000 (21:34 +0000)
committerJames Turner <zakalawe@mac.com>
Sun, 1 Dec 2013 21:37:17 +0000 (21:37 +0000)
- make the FDM owned via a SGSharedPtr
- drop some property references explicitly.

src/FDM/fdm_shell.cxx
src/FDM/fdm_shell.hxx

index cb3805d7b88d656f492ed4d2e17285e1da22a0d4..dd5de9eb6cf3ab286a54bcdca2dcc7aec2766fe5 100644 (file)
@@ -63,14 +63,13 @@ using std::string;
 
 FDMShell::FDMShell() :
   _tankProperties( fgGetNode("/consumables/fuel", true) ),
-  _impl(NULL),
   _dataLogging(false)
 {
 }
 
 FDMShell::~FDMShell()
 {
-  delete _impl;
+    SG_LOG(SG_GENERAL, SG_INFO, "destorying FDM shell");
 }
 
 void FDMShell::init()
@@ -91,15 +90,29 @@ void FDMShell::init()
   createImplementation();
 }
 
+void FDMShell::shutdown()
+{
+    if (_impl) {
+        fgSetBool("/sim/fdm-initialized", false);
+        _impl->unbind();
+        _impl.clear();
+    }
+    
+    _props.clear();
+    _wind_north.clear();
+    _wind_east.clear();
+    _wind_down.clear();
+    _control_fdm_atmo.clear();
+    _temp_degc.clear();
+    _pressure_inhg.clear();
+    _density_slugft .clear();
+    _data_logging.clear();
+    _replay_master.clear();
+}
+
 void FDMShell::reinit()
 {
-  if (_impl) {
-    fgSetBool("/sim/fdm-initialized", false);
-    _impl->unbind();
-    delete _impl;
-    _impl = NULL;
-  }
-  
+  shutdown();
   init();
 }
 
index 9beb293e15cb3ac02eea929514a761571d3f0fe1..0eb576609ecd8b2e85d616579e019f20bc61efc7 100644 (file)
@@ -44,6 +44,7 @@ public:
   virtual ~FDMShell();
   
   virtual void init();
+  virtual void shutdown();
   virtual void reinit();
   
   virtual void bind();
@@ -57,7 +58,7 @@ private:
   void createImplementation();
   
   TankPropertiesList _tankProperties;
-  FGInterface* _impl;
+  SGSharedPtr<FGInterface> _impl;
   SGPropertyNode_ptr _props; // root property tree for this FDM instance
   bool _dataLogging;