From 6044d929d409b379b4e2df0fff9e62600f103ef7 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 26 Jan 2010 17:19:17 +0100 Subject: [PATCH] eliminate some SGPropertyNode_ptr variables in classes These were temporary variables that were being deleted explicitly, leading to various corruption. --- src/Instrumentation/instrument_mgr.cxx | 8 +++----- src/Instrumentation/instrument_mgr.hxx | 3 +-- src/Systems/electrical.cxx | 7 +++---- src/Systems/electrical.hxx | 3 +-- src/Systems/system_mgr.cxx | 7 +++---- src/Systems/system_mgr.hxx | 3 +-- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx index 380ccd2ee..6bfecbb27 100644 --- a/src/Instrumentation/instrument_mgr.cxx +++ b/src/Instrumentation/instrument_mgr.cxx @@ -57,7 +57,7 @@ FGInstrumentMgr::FGInstrumentMgr () : set_subsystem("od_gauge", new FGODGauge); set_subsystem("hud", new HUD); - config_props = new SGPropertyNode; + SGPropertyNode_ptr config_props = new SGPropertyNode; SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path"); @@ -70,7 +70,7 @@ FGInstrumentMgr::FGInstrumentMgr () : try { readProperties( config.str(), config_props ); - if ( !build() ) { + if ( !build(config_props) ) { throw sg_error( "Detected an internal inconsistency in the instrumentation\n" "system specification file. See earlier errors for details."); @@ -85,8 +85,6 @@ FGInstrumentMgr::FGInstrumentMgr () : "No instrumentation model specified for this model!"); } - delete config_props; - if (!_explicitGps) { SG_LOG(SG_INSTR, SG_INFO, "creating default GPS instrument"); SGPropertyNode_ptr nd(new SGPropertyNode); @@ -100,7 +98,7 @@ FGInstrumentMgr::~FGInstrumentMgr () { } -bool FGInstrumentMgr::build () +bool FGInstrumentMgr::build (SGPropertyNode* config_props) { for ( int i = 0; i < config_props->nChildren(); ++i ) { SGPropertyNode *node = config_props->getChild(i); diff --git a/src/Instrumentation/instrument_mgr.hxx b/src/Instrumentation/instrument_mgr.hxx index 8224e85f5..b5856ef97 100644 --- a/src/Instrumentation/instrument_mgr.hxx +++ b/src/Instrumentation/instrument_mgr.hxx @@ -31,10 +31,9 @@ public: FGInstrumentMgr (); virtual ~FGInstrumentMgr (); - bool build (); + bool build (SGPropertyNode* config_props); private: - SGPropertyNode_ptr config_props; bool _explicitGps; }; diff --git a/src/Systems/electrical.cxx b/src/Systems/electrical.cxx index 045d62207..103456a48 100644 --- a/src/Systems/electrical.cxx +++ b/src/Systems/electrical.cxx @@ -348,7 +348,7 @@ FGElectricalSystem::~FGElectricalSystem () { void FGElectricalSystem::init () { - config_props = new SGPropertyNode; + SGPropertyNode_ptr config_props = new SGPropertyNode; _volts_out = fgGetNode( "/systems/electrical/volts", true ); _amps_out = fgGetNode( "/systems/electrical/amps", true ); @@ -381,7 +381,7 @@ void FGElectricalSystem::init () { try { readProperties( config.str(), config_props ); - if ( build() ) { + if ( build(config_props) ) { enabled = true; } else { SG_LOG( SG_ALL, SG_ALERT, @@ -406,7 +406,6 @@ void FGElectricalSystem::init () { _amps_out->setDoubleValue(0); } - delete config_props; } @@ -553,7 +552,7 @@ void FGElectricalSystem::update (double dt) { } -bool FGElectricalSystem::build () { +bool FGElectricalSystem::build (SGPropertyNode* config_props) { SGPropertyNode *node; int i; diff --git a/src/Systems/electrical.hxx b/src/Systems/electrical.hxx index c63b8c35f..f6f21a453 100644 --- a/src/Systems/electrical.hxx +++ b/src/Systems/electrical.hxx @@ -251,7 +251,7 @@ public: virtual void unbind (); virtual void update (double dt); - bool build (); + bool build (SGPropertyNode* config_props); float propagate( FGElectricalComponent *node, double dt, float input_volts, float input_amps, string s = "" ); @@ -266,7 +266,6 @@ private: string name; int num; string path; - SGPropertyNode_ptr config_props; bool enabled; diff --git a/src/Systems/system_mgr.cxx b/src/Systems/system_mgr.cxx index 9d945a584..4936ea638 100644 --- a/src/Systems/system_mgr.cxx +++ b/src/Systems/system_mgr.cxx @@ -29,7 +29,7 @@ FGSystemMgr::FGSystemMgr () { - config_props = new SGPropertyNode; + SGPropertyNode_ptr config_props = new SGPropertyNode; SGPropertyNode *path_n = fgGetNode("/sim/systems/path"); @@ -42,7 +42,7 @@ FGSystemMgr::FGSystemMgr () try { readProperties( config.str(), config_props ); - if ( build() ) { + if ( build(config_props) ) { enabled = true; } else { SG_LOG( SG_ALL, SG_ALERT, @@ -63,14 +63,13 @@ FGSystemMgr::FGSystemMgr () "No systems model specified for this model!"); } - delete config_props; } FGSystemMgr::~FGSystemMgr () { } -bool FGSystemMgr::build () +bool FGSystemMgr::build (SGPropertyNode* config_props) { SGPropertyNode *node; int i; diff --git a/src/Systems/system_mgr.hxx b/src/Systems/system_mgr.hxx index a5403580f..a6260a531 100644 --- a/src/Systems/system_mgr.hxx +++ b/src/Systems/system_mgr.hxx @@ -31,10 +31,9 @@ public: FGSystemMgr (); virtual ~FGSystemMgr (); - bool build (); + bool build (SGPropertyNode* config_props); private: - SGPropertyNode_ptr config_props; bool enabled; };