1
0
Fork 0

- move data structure allocation into constructor (it doesn't belong

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
This commit is contained in:
curt 2001-07-11 18:54:50 +00:00
parent 4b23576df1
commit b338698c79
2 changed files with 26 additions and 22 deletions

View 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);

View 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;