]> git.mxchange.org Git - flightgear.git/commitdiff
eliminate some SGPropertyNode_ptr variables in classes
authorTim Moore <timoore@redhat.com>
Tue, 26 Jan 2010 16:19:17 +0000 (17:19 +0100)
committerTim Moore <timoore@redhat.com>
Tue, 26 Jan 2010 16:19:17 +0000 (17:19 +0100)
These were temporary variables that were being deleted explicitly, leading to
various corruption.

src/Instrumentation/instrument_mgr.cxx
src/Instrumentation/instrument_mgr.hxx
src/Systems/electrical.cxx
src/Systems/electrical.hxx
src/Systems/system_mgr.cxx
src/Systems/system_mgr.hxx

index 380ccd2ee8bae6dbae57b02ace3ebc969a2e675b..6bfecbb270968d540253735f1fd426cddf07c9ca 100644 (file)
@@ -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);
index 8224e85f58a134f4061b53e05710771291d84352..b5856ef979de8e0da90be5ff5e4183db7e1a6ede 100644 (file)
@@ -31,10 +31,9 @@ public:
 
     FGInstrumentMgr ();
     virtual ~FGInstrumentMgr ();
-    bool build ();
+    bool build (SGPropertyNode* config_props);
 
 private:
-    SGPropertyNode_ptr config_props;
     bool _explicitGps;
 };
 
index 045d6220743b8858641d6fe75d6dce486b381f83..103456a485b899ecb1f6f3ddb21ebb14a69798e1 100644 (file)
@@ -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;
 
index c63b8c35f564a24e58bafe0037feb807ae1f3bfc..f6f21a4534a653f958f86dd73ab6ae1de2d8af43 100644 (file)
@@ -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;
 
index 9d945a5849f3adeaed68acea0f3cfedcc25dbc86..4936ea63818fec9a43fe5ceaac56d9fb75ff18ed 100644 (file)
@@ -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;
index a5403580fe3ca08716831d5b03d8626843fc3da2..a6260a531d921d3213c1cee94b63666ef16be58b 100644 (file)
@@ -31,10 +31,9 @@ public:
 
     FGSystemMgr ();
     virtual ~FGSystemMgr ();
-    bool build ();
+    bool build (SGPropertyNode* config_props);
 
 private:
-    SGPropertyNode_ptr config_props;
     bool enabled;
 
 };