Skip to content

Commit 3deeff1

Browse files
committed
Removed superfluous dataBuffer in graph_spectrum to prevent the random spectrum type change bug
1 parent 900c0df commit 3deeff1

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

src/graph_spectrum.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
100100
});
101101
};
102102

103-
let dataLoad = function () {
104-
GraphSpectrumCalc.setDataBuffer(dataBuffer);
103+
const dataLoad = function (fieldIndex, curve, fieldName) {
104+
if (fieldIndex > 0 && curve != null && fieldName != null) {
105+
GraphSpectrumCalc.setDataBuffer(fieldIndex, curve, fieldName);
106+
}
105107

106108
switch (userSettings.spectrumType) {
107109
case SPECTRUM_TYPE.FREQ_VS_THROTTLE:
@@ -127,15 +129,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
127129
It is only used to record the current curve positions, collect the data and draw the
128130
analyser on screen*/
129131
this.plotSpectrum = function (fieldIndex, curve, fieldName) {
130-
// Store the data pointers
131-
dataBuffer.fieldIndex = fieldIndex;
132-
dataBuffer.curve = curve;
133-
dataBuffer.fieldName = fieldName;
134-
135132
// Detect change of selected field.... reload and redraw required.
136133
if (fftData == null || fieldIndex != fftData.fieldIndex || dataReload) {
137134
dataReload = false;
138-
dataLoad();
135+
dataLoad(fieldIndex, curve, fieldName);
139136
GraphSpectrumPlot.setData(fftData, userSettings.spectrumType);
140137
}
141138

@@ -206,20 +203,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
206203
userSettings.spectrumType = optionSelected;
207204
saveOneUserSetting("spectrumType", userSettings.spectrumType);
208205

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-
}
216206
// Recalculate the data, for the same curve than now, and draw it
217207
dataReload = true;
218-
that.plotSpectrum(
219-
dataBuffer.fieldIndex,
220-
dataBuffer.curve,
221-
dataBuffer.fieldName,
222-
);
208+
that.plotSpectrum(-1, null, null); // Update fft data only
223209
}
224210

225211
// Hide overdraw and zoomY if needed

src/graph_spectrum_calc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ GraphSpectrumCalc.setOutTime = function(time) {
8484
return this._analyserTimeRange.out;
8585
};
8686

87-
GraphSpectrumCalc.setDataBuffer = function(dataBuffer) {
88-
this._dataBuffer.curve = dataBuffer.curve;
89-
this._dataBuffer.fieldName = dataBuffer.fieldName;
90-
this._dataBuffer.fieldIndex = dataBuffer.fieldIndex;
87+
GraphSpectrumCalc.setDataBuffer = function(fieldIndex, curve, fieldName) {
88+
this._dataBuffer.curve = curve;
89+
this._dataBuffer.fieldName = fieldName;
90+
this._dataBuffer.fieldIndex = fieldIndex;
9191
return undefined;
9292
};
9393

0 commit comments

Comments
 (0)