]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFDMExec.cpp
Fix a segfault on exit. Introduces a small memory leak if the instrument
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.cpp
index 32359bb3c256befc175262b930331c7efabcb082..ed10e6986e958f6a090e0456c3b5d4559672481e 100644 (file)
@@ -43,9 +43,9 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #ifdef FGFS
+#  include <time.h>
 #  include <simgear/compiler.h>
 #  include STL_IOSTREAM
-#  include <time.h>
 #  include STL_ITERATOR
 #else
 #  include <iostream>
@@ -364,14 +364,26 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model)
 {
   bool result = false;
 
+  string aircraftCfgFileName;
+
+  AircraftPath = APath;
+  EnginePath   = EPath;
+
+# ifndef macintosh
+  aircraftCfgFileName = AircraftPath + "/" + model + "/" + model + ".xml";
+# else
+  aircraftCfgFileName = AircraftPath + ";" + model + ";" + model + ".xml";
+# endif
+
+  FGConfigFile AC_cfg(aircraftCfgFileName);
+  if (!AC_cfg.IsOpen()) return false;
+
   if (modelLoaded) {
     DeAllocate();
     Allocate();
   }
 
-  AircraftPath = APath;
-  EnginePath   = EPath;
-  result = Aircraft->LoadAircraft(AircraftPath, EnginePath, model);
+  result = Aircraft->Load(&AC_cfg);
 
   if (result) {
     modelLoaded = true;