]> git.mxchange.org Git - flightgear.git/commitdiff
autopilot filter deque fixes
authortimoore <timoore>
Mon, 24 Mar 2008 22:46:47 +0000 (22:46 +0000)
committertimoore <timoore>
Mon, 24 Mar 2008 22:46:47 +0000 (22:46 +0000)
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.

src/Autopilot/xmlauto.cxx
src/Instrumentation/mk_viii.cxx
src/Instrumentation/mk_viii.hxx

index 93efccb27b4a9583116311669dc587234399f5e8..03344d33e5876624d8fa3cdb29a291e8d479da1a 100644 (file)
@@ -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)
         {
index 118d740b70e64584758f257e336d4d9fa9e6bfe4..43cbb1e842edbad5ef9491a4f586b730815e211e 100755 (executable)
@@ -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<double> >::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<double> > >::iterator erase_last = altitude_samples.begin();
-  deque< Sample< Parameter<double> > >::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)
index 47b76440f448d5aa17a0dad41cc23b57b8e93386..722abddf0db227ea276b638d79a2f9bd9750266b 100755 (executable)
@@ -621,7 +621,8 @@ public:
 
     class TerrainClearanceFilter
     {
-      deque< Sample<double> >  samples;
+      typedef deque< Sample<double> > 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<double> > > altitude_samples;
+    typedef deque< Sample< Parameter<double> > > altitude_samples_type;
+    altitude_samples_type altitude_samples;
 
     struct
     {