@@ -804,17 +804,26 @@ void VNA::initializeDevice()
804804 QSettings s;
805805 auto key = " DefaultCalibration" +window->getDevice ()->getSerial ();
806806 if (s.contains (key)) {
807- auto filename = s.value (key).toString ();
808- qDebug () << " Attempting to load default calibration file " << filename;
809- if (QFile::exists (filename)) {
810- if (cal.fromFile (filename)) {
811- qDebug () << " Calibration successful from " << filename;
807+
808+ // only load default calibration once per device. This allows the user to switch to a different calibration
809+ // and have it persist across device initializations. Only when connecting to the device again should the
810+ // default calibration be loaded
811+ if (defaultCalSerial != window->getDevice ()->getSerial ()) {
812+ // we have never loaded the default calibration for this device, do so now
813+ auto filename = s.value (key).toString ();
814+ qDebug () << " Attempting to load default calibration file " << filename;
815+ if (QFile::exists (filename)) {
816+ if (cal.fromFile (filename)) {
817+ qDebug () << " Calibration successful from " << filename;
818+ defaultCalSerial = window->getDevice ()->getSerial ();
819+ } else {
820+ qDebug () << " Calibration not successfull from: " << filename;
821+ }
812822 } else {
813- qDebug () << " Calibration not successfull from : " << filename;
823+ qDebug () << " Calibration file not found : " << filename;
814824 }
815- } else {
816- qDebug () << " Calibration file not found: " << filename;
817825 }
826+
818827 removeDefaultCal->setEnabled (true );
819828 } else {
820829 qDebug () << " No default calibration file set for this device" ;
@@ -833,6 +842,8 @@ void VNA::initializeDevice()
833842void VNA::deviceDisconnected ()
834843{
835844 defaultCalMenu->setEnabled (false );
845+ qDebug () << " disconnected" ;
846+ defaultCalSerial.clear ();
836847 emit sweepStopped ();
837848}
838849
0 commit comments