@@ -17,14 +17,14 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
1717 let that = this ,
1818 analyserZoomX = 1.0 /* 100% */ ,
1919 analyserZoomY = 1.0 /* 100% */ ,
20+ dataReload = false ,
21+ fftData = null ,
22+ prefs = new PrefStorage ( ) ,
2023 dataBuffer = {
2124 fieldIndex : 0 ,
22- curve : 0 ,
25+ curve : null ,
2326 fieldName : null ,
24- } ,
25- dataReload = false ,
26- fftData = null ,
27- prefs = new PrefStorage ( ) ;
27+ } ;
2828
2929 try {
3030 let isFullscreen = false ;
@@ -128,11 +128,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
128128 analyser on screen*/
129129 this . plotSpectrum = function ( fieldIndex , curve , fieldName ) {
130130 // Store the data pointers
131- dataBuffer = {
132- fieldIndex : fieldIndex ,
133- curve : curve ,
134- fieldName : fieldName ,
135- } ;
131+ dataBuffer . fieldIndex = fieldIndex ;
132+ dataBuffer . curve = curve ;
133+ dataBuffer . fieldName = fieldName ;
136134
137135 // Detect change of selected field.... reload and redraw required.
138136 if ( fftData == null || fieldIndex != fftData . fieldIndex || dataReload ) {
@@ -208,6 +206,13 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
208206 userSettings . spectrumType = optionSelected ;
209207 saveOneUserSetting ( "spectrumType" , userSettings . spectrumType ) ;
210208
209+ // Restore dataBuffer if it was corrupted
210+ if ( ! dataBuffer . curve ) {
211+ dataBuffer . curve = GraphSpectrumCalc . _dataBuffer . curve ;
212+ dataBuffer . fieldName = GraphSpectrumCalc . _dataBuffer . fieldName ;
213+ dataBuffer . fieldIndex = GraphSpectrumCalc . _dataBuffer . fieldIndex ;
214+ console . warn ( "The dataBuffer was corrupted (set to default zeroes) in FlightLogAnalyser.spectrumTypeElem.change event" ) ;
215+ }
211216 // Recalculate the data, for the same curve than now, and draw it
212217 dataReload = true ;
213218 that . plotSpectrum (
0 commit comments