From bad8ecba4980b97fd9004a83fec86f43d89199d8 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Fri, 13 Jan 2023 22:43:42 +0100 Subject: [PATCH] Fixed needless config saves --- core/src/gui/main_window.cpp | 15 ++++++++++----- misc_modules/rigctl_server/src/main.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp index b6ec07bf..869c8129 100644 --- a/core/src/gui/main_window.cpp +++ b/core/src/gui/main_window.cpp @@ -548,22 +548,27 @@ void MainWindow::draw() { if (!lockWaterfallControls) { // Handle arrow keys if (vfo != NULL && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) { + bool freqChanged = false; if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow) && !gui::freqSelect.digitHovered) { double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset - vfo->snapInterval; nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval; tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq); + freqChanged = true; } if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) && !gui::freqSelect.digitHovered) { double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + vfo->snapInterval; nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval; tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq); + freqChanged = true; } - core::configManager.acquire(); - core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency(); - if (vfo != NULL) { - core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset; + if (freqChanged) { + core::configManager.acquire(); + core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency(); + if (vfo != NULL) { + core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset; + } + core::configManager.release(true); } - core::configManager.release(true); } // Handle scrollwheel diff --git a/misc_modules/rigctl_server/src/main.cpp b/misc_modules/rigctl_server/src/main.cpp index 8495c3dc..2b78eed3 100644 --- a/misc_modules/rigctl_server/src/main.cpp +++ b/misc_modules/rigctl_server/src/main.cpp @@ -145,11 +145,11 @@ private: std::lock_guard lck(_this->vfoMtx); if (ImGui::Combo(CONCAT("##_rigctl_srv_rec_", _this->name), &_this->recorderId, _this->recorderNamesTxt.c_str())) { _this->selectRecorderByName(_this->recorderNames[_this->recorderId], false); - } - if (!_this->selectedRecorder.empty()) { - config.acquire(); - config.conf[_this->name]["recorder"] = _this->selectedRecorder; - config.release(true); + if (!_this->selectedRecorder.empty()) { + config.acquire(); + config.conf[_this->name]["recorder"] = _this->selectedRecorder; + config.release(true); + } } }