From d530b2a2132dbe8d009643bf516e83e8d10b062e Mon Sep 17 00:00:00 2001 From: Kiara Navarro Date: Sun, 3 Jul 2022 16:43:01 -0500 Subject: [PATCH] app: prevent update preferences in none active and destroyed modes --- Software/PC_Application/appwindow.cpp | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Software/PC_Application/appwindow.cpp b/Software/PC_Application/appwindow.cpp index 4101a5b..6145eba 100644 --- a/Software/PC_Application/appwindow.cpp +++ b/Software/PC_Application/appwindow.cpp @@ -271,24 +271,31 @@ AppWindow::AppWindow(QWidget *parent) } } - auto active = Mode::getActiveMode(); - active->updateGraphColors(); - // averaging mode may have changed, update for all relevant modes - if(p.Acquisition.useMedianAveraging) { - spectrumAnalyzer->setAveragingMode(Averaging::Mode::Median); - vna->setAveragingMode(Averaging::Mode::Median); - } else { - spectrumAnalyzer->setAveragingMode(Averaging::Mode::Mean); - vna->setAveragingMode(Averaging::Mode::Mean); + if (spectrumAnalyzer || vna) + { + if(p.Acquisition.useMedianAveraging) { + spectrumAnalyzer->setAveragingMode(Averaging::Mode::Median); + vna->setAveragingMode(Averaging::Mode::Median); + } else { + spectrumAnalyzer->setAveragingMode(Averaging::Mode::Mean); + vna->setAveragingMode(Averaging::Mode::Mean); + } } // acquisition frequencies may have changed, update UpdateAcquisitionFrequencies(); - if(device) { - active->initializeDevice(); + auto active = Mode::getActiveMode(); + if (active) + { + active->updateGraphColors(); + + if(device) { + active->initializeDevice(); + } } + }); connect(ui->actionAbout, &QAction::triggered, [=](){