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 // Constructor
FGRadioStack::FGRadioStack() { FGRadioStack::FGRadioStack() :
nav1_radial = 0.0; lon_node(fgGetNode("/position/longitude-deg", true)),
nav1_dme_dist = 0.0; lat_node(fgGetNode("/position/latitude-deg", true)),
nav2_radial = 0.0; alt_node(fgGetNode("/position/altitude-ft", true)),
nav2_dme_dist = 0.0; need_update(true),
need_update = true; nav1_radial(0.0),
lon_node = fgGetNode("/position/longitude-deg"); nav1_dme_dist(0.0),
lat_node = fgGetNode("/position/latitude-deg"); nav2_radial(0.0),
alt_node = fgGetNode("/position/altitude-ft"); 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() FGRadioStack::~FGRadioStack()
{ {
unbind(); // FIXME: should be called externally unbind(); // FIXME: should be called externally
delete term_tbl;
delete low_tbl;
delete high_tbl;
} }
@ -107,18 +123,6 @@ FGRadioStack::init ()
search(); search();
update(); 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 // Search radio database once per second
global_events.Register( "fgRadioSearch()", fgRadioSearch, global_events.Register( "fgRadioSearch()", fgRadioSearch,
fgEVENT::FG_EVENT_READY, 1000); fgEVENT::FG_EVENT_READY, 1000);

View file

@ -48,8 +48,8 @@ class FGRadioStack : public FGSubsystem
SGInterpTable *low_tbl; SGInterpTable *low_tbl;
SGInterpTable *high_tbl; SGInterpTable *high_tbl;
SGPropertyNode *lat_node;
SGPropertyNode *lon_node; SGPropertyNode *lon_node;
SGPropertyNode *lat_node;
SGPropertyNode *alt_node; SGPropertyNode *alt_node;
bool need_update; bool need_update;