From: Frederic Bouvier Date: Fri, 29 Oct 2010 07:00:31 +0000 (+0200) Subject: Don't blindly delete the global property tree on reinit X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6081f24b006f6adb6d8c8320c65ccdaad1ca4f19;p=flightgear.git Don't blindly delete the global property tree on reinit --- diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index bc81cd6f8..f02d23e64 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -96,14 +96,14 @@ void checkTied ( FGPropertyManager *node ) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Constructors -FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root) +FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root), delete_root(false) { FDMctr = new unsigned int; *FDMctr = 0; Initialize(); } -FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr) +FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), delete_root(false), FDMctr(fdmctr) { Initialize(); } @@ -150,6 +150,7 @@ void FGFDMExec::Initialize() if (Root == 0) { // Then this is the root FDM Root = new FGPropertyManager; // Create the property manager + delete_root = true; FDMctr = new unsigned int; // Create and initialize the child FDM counter (*FDMctr) = 0; @@ -196,7 +197,8 @@ FGFDMExec::~FGFDMExec() if (IdFDM == 0) { // Meaning this is no child FDM if(Root != 0) { - delete Root; + if (delete_root) + delete Root; Root = 0; } if(FDMctr != 0) { diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h index 231cadcaa..331097182 100644 --- a/src/FDM/JSBSim/FGFDMExec.h +++ b/src/FDM/JSBSim/FGFDMExec.h @@ -555,6 +555,7 @@ private: FGTrim* Trim; FGPropertyManager* Root; + bool delete_root; FGPropertyManager* instance; // The FDM counter is used to give each child FDM an unique ID. The root FDM has the ID 0