Skip to content

Commit

Permalink
don't crash app on insufficient/invalid cal data fixes #699
Browse files Browse the repository at this point in the history
  • Loading branch information
zarath committed Jun 25, 2024
1 parent ca5ed1e commit 372faef
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/NanoVNASaver/Windows/CalibrationSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,13 @@ def calculate(self):
)
return

if not self.app.calibration.isValid1Port():
self.app.showError(
"Not enough data to apply calibration."
" Please complete SOL calibration and try again."
)
return

cal_element.short_is_ideal = True
cal_element.open_is_ideal = True
cal_element.load_is_ideal = True
Expand Down Expand Up @@ -633,18 +640,20 @@ def calculate(self):
self.app.sweepSource,
)
self.app.worker.signals.updated.emit()

except ValueError as e:
if logger.isEnabledFor(logging.DEBUG):
raise
# showError here hides the calibration window,
# so we need to pop up our own
QtWidgets.QMessageBox.warning(
self, "Error applying calibration", str(e)
)
self.calibration_status_label.setText(
"Applying calibration failed."
)
self.calibration_source_label.setText(self.app.calibration.source)
self.app.showError(
f"{e}"
" Please complete SOL calibration and try again."
)
self.reset()
return

def loadCalibration(self):
filename, _ = QtWidgets.QFileDialog.getOpenFileName(
Expand Down

0 comments on commit 372faef

Please sign in to comment.