From 61788d655863cd20f3ac5fd2fcaa59860f23bd14 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Fri, 29 Oct 2010 09:10:07 +0200 Subject: [PATCH] temporary fix for a crash of the c172 (and possibly other aircraft) --- src/FDM/JSBSim/FGFDMExec.cpp | 6 ++++-- src/FDM/JSBSim/FGFDMExec.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index bc81cd6f8..6a12cec2b 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -101,11 +101,13 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root) FDMctr = new unsigned int; *FDMctr = 0; Initialize(); + root_overload = (root != NULL); } FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr) { Initialize(); + root_overload = (root != NULL); } void FGFDMExec::Initialize() @@ -194,12 +196,12 @@ FGFDMExec::~FGFDMExec() checkTied( instance ); DeAllocate(); - if (IdFDM == 0) { // Meaning this is no child FDM + if(FDMctr != 0 && !root_overload) { if(Root != 0) { delete Root; Root = 0; } - if(FDMctr != 0) { + if (IdFDM == 0) { // Meaning this is no child FDM delete FDMctr; FDMctr = 0; } diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h index 231cadcaa..9d53cd1b5 100644 --- a/src/FDM/JSBSim/FGFDMExec.h +++ b/src/FDM/JSBSim/FGFDMExec.h @@ -524,6 +524,7 @@ private: bool Constructing; bool modelLoaded; bool IsChild; + bool root_overload; string modelName; string AircraftPath; string FullAircraftPath; -- 2.39.5