From 1615bb419a82d61bba1b05f5b2264604fc51c966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Wed, 11 Feb 2026 15:06:17 +0100 Subject: [PATCH] only load default calibration when connecting to device --- .../PC_Application/LibreVNA-GUI/VNA/vna.cpp | 27 +++++++++++++------ .../PC_Application/LibreVNA-GUI/VNA/vna.h | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp index 8144dc0..909005b 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp @@ -804,17 +804,26 @@ void VNA::initializeDevice() QSettings s; auto key = "DefaultCalibration"+window->getDevice()->getSerial(); if (s.contains(key)) { - auto filename = s.value(key).toString(); - qDebug() << "Attempting to load default calibration file " << filename; - if(QFile::exists(filename)) { - if(cal.fromFile(filename)) { - qDebug() << "Calibration successful from " << filename; + + // only load default calibration once per device. This allows the user to switch to a different calibration + // and have it persist across device initializations. Only when connecting to the device again should the + // default calibration be loaded + if(defaultCalSerial != window->getDevice()->getSerial()) { + // we have never loaded the default calibration for this device, do so now + auto filename = s.value(key).toString(); + qDebug() << "Attempting to load default calibration file " << filename; + if(QFile::exists(filename)) { + if(cal.fromFile(filename)) { + qDebug() << "Calibration successful from " << filename; + defaultCalSerial = window->getDevice()->getSerial(); + } else { + qDebug() << "Calibration not successfull from: " << filename; + } } else { - qDebug() << "Calibration not successfull from: " << filename; + qDebug() << "Calibration file not found: " << filename; } - } else { - qDebug() << "Calibration file not found: " << filename; } + removeDefaultCal->setEnabled(true); } else { qDebug() << "No default calibration file set for this device"; @@ -833,6 +842,8 @@ void VNA::initializeDevice() void VNA::deviceDisconnected() { defaultCalMenu->setEnabled(false); + qDebug() << "disconnected"; + defaultCalSerial.clear(); emit sweepStopped(); } diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.h b/Software/PC_Application/LibreVNA-GUI/VNA/vna.h index f593e08..2d9cee1 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.h +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.h @@ -180,6 +180,7 @@ private: QMenu *defaultCalMenu; QAction *assignDefaultCal, *removeDefaultCal; + QString defaultCalSerial; QAction *saveCal; Deembedding deembedding;