]> git.mxchange.org Git - flightgear.git/commitdiff
- move data structure allocation into constructor (it doesn't belong
authorcurt <curt>
Wed, 11 Jul 2001 18:54:50 +0000 (18:54 +0000)
committercurt <curt>
Wed, 11 Jul 2001 18:54:50 +0000 (18:54 +0000)
  in init)
- free data structures in destructor
- ensure that interpolation tables are allocated before any searching
  is done; otherwise, starting at some locations (such as CYYZ) causes
  a segfault

src/Cockpit/radiostack.cxx
src/Cockpit/radiostack.hxx

index bc41bbb9c4833ff8c0d8d7f85fbaed29beee8d2c..86057264d30684a7534ca1a123338a867b4641c2 100644 (file)
@@ -78,15 +78,27 @@ static void fgRadioSearch( void ) {
 }
 
 // Constructor
-FGRadioStack::FGRadioStack() {
-    nav1_radial = 0.0;
-    nav1_dme_dist = 0.0;
-    nav2_radial = 0.0;
-    nav2_dme_dist = 0.0;
-    need_update = true;
-    lon_node = fgGetNode("/position/longitude-deg");
-    lat_node = fgGetNode("/position/latitude-deg");
-    alt_node = fgGetNode("/position/altitude-ft");
+FGRadioStack::FGRadioStack() :
+    lon_node(fgGetNode("/position/longitude-deg", true)),
+    lat_node(fgGetNode("/position/latitude-deg", true)),
+    alt_node(fgGetNode("/position/altitude-ft", true)),
+    need_update(true),
+    nav1_radial(0.0),
+    nav1_dme_dist(0.0),
+    nav2_radial(0.0),
+    nav2_dme_dist(0.0)
+{
+    SGPath path( globals->get_fg_root() );
+    SGPath term = path;
+    term.append( "Navaids/range.term" );
+    SGPath low = path;
+    low.append( "Navaids/range.low" );
+    SGPath high = path;
+    high.append( "Navaids/range.high" );
+
+    term_tbl = new SGInterpTable( term.str() );
+    low_tbl = new SGInterpTable( low.str() );
+    high_tbl = new SGInterpTable( high.str() );
 }
 
 
@@ -94,6 +106,10 @@ FGRadioStack::FGRadioStack() {
 FGRadioStack::~FGRadioStack() 
 {
     unbind();                  // FIXME: should be called externally
+
+    delete term_tbl;
+    delete low_tbl;
+    delete high_tbl;
 }
 
 
@@ -107,18 +123,6 @@ FGRadioStack::init ()
     search();
     update();
 
-    SGPath path( globals->get_fg_root() );
-    SGPath term = path;
-    term.append( "Navaids/range.term" );
-    SGPath low = path;
-    low.append( "Navaids/range.low" );
-    SGPath high = path;
-    high.append( "Navaids/range.high" );
-
-    term_tbl = new SGInterpTable( term.str() );
-    low_tbl = new SGInterpTable( low.str() );
-    high_tbl = new SGInterpTable( high.str() );
-
     // Search radio database once per second
     global_events.Register( "fgRadioSearch()", fgRadioSearch,
                            fgEVENT::FG_EVENT_READY, 1000);
index cf88735233c351e318d6cc1e04416484e21810be..764b4bf5ecc931de46b8f454586053defcfde1ec 100644 (file)
@@ -48,8 +48,8 @@ class FGRadioStack : public FGSubsystem
     SGInterpTable *low_tbl;
     SGInterpTable *high_tbl;
 
-    SGPropertyNode *lat_node;
     SGPropertyNode *lon_node;
+    SGPropertyNode *lat_node;
     SGPropertyNode *alt_node;
 
     bool need_update;