From: timoore Date: Mon, 24 Mar 2008 22:46:47 +0000 (+0000) Subject: autopilot filter deque fixes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d28b509e5fbf113a6629d5af69b41c814659c263;p=flightgear.git autopilot filter deque fixes Thanks to Vivian Meazza for debugging this. The output deque for FGDigitalFilter was not being kept long enough for the doubleExponential filter. Reads from output[1] could cause a crash. --- diff --git a/src/Autopilot/xmlauto.cxx b/src/Autopilot/xmlauto.cxx index 93efccb27..03344d33e 100644 --- a/src/Autopilot/xmlauto.cxx +++ b/src/Autopilot/xmlauto.cxx @@ -742,7 +742,6 @@ void FGDigitalFilter::update(double dt) // first time being enabled, initialize output to the // value of the output property to avoid bumping. output.push_front(output_list[0]->getDoubleValue()); - output.resize(1); } enabled = true; @@ -821,7 +820,7 @@ void FGDigitalFilter::update(double dt) for ( i = 0; i < output_list.size(); ++i ) { output_list[i]->setDoubleValue( output[0] ); } - output.resize(1); + output.resize(2); if (debug) { diff --git a/src/Instrumentation/mk_viii.cxx b/src/Instrumentation/mk_viii.cxx index 118d740b7..43cbb1e84 100755 --- a/src/Instrumentation/mk_viii.cxx +++ b/src/Instrumentation/mk_viii.cxx @@ -1008,7 +1008,7 @@ MK_VIII::IOHandler::TerrainClearanceFilter::update (double agl) // [PILOT] page 20 specifies that the terrain clearance is equal to // 75% of the radio altitude, averaged over the previous 15 seconds. - deque< Sample >::iterator iter; + samples_type::iterator iter; // remove samples older than 15 seconds for (iter = samples.begin(); iter != samples.end() && globals->get_sim_time_sec() - (*iter).timestamp >= 15; iter = samples.begin()) @@ -1267,8 +1267,8 @@ MK_VIII::IOHandler::update_inputs () // Erase everything from the beginning of the list up to the sample // preceding the most recent sample whose age is >= 1 second. - deque< Sample< Parameter > >::iterator erase_last = altitude_samples.begin(); - deque< Sample< Parameter > >::iterator iter; + altitude_samples_type::iterator erase_last = altitude_samples.begin(); + altitude_samples_type::iterator iter; for (iter = altitude_samples.begin(); iter != altitude_samples.end(); iter++) if (globals->get_sim_time_sec() - (*iter).timestamp >= 1) diff --git a/src/Instrumentation/mk_viii.hxx b/src/Instrumentation/mk_viii.hxx index 47b76440f..722abddf0 100755 --- a/src/Instrumentation/mk_viii.hxx +++ b/src/Instrumentation/mk_viii.hxx @@ -621,7 +621,8 @@ public: class TerrainClearanceFilter { - deque< Sample > samples; + typedef deque< Sample > samples_type; + samples_type samples; double value; public: @@ -654,7 +655,8 @@ public: bool last_landing_gear; bool last_real_flaps_down; - deque< Sample< Parameter > > altitude_samples; + typedef deque< Sample< Parameter > > altitude_samples_type; + altitude_samples_type altitude_samples; struct {