From b2191c5d2cfbedda9ccfc9095170a0e1c880be77 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sun, 16 Aug 2020 18:18:10 +0200 Subject: [PATCH] Fixed delete[] in soapy.h --- src/main_window.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main_window.cpp b/src/main_window.cpp index 2c600ee7..f494af54 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -70,12 +70,7 @@ void saveCurrentSource() { void loadSourceConfig(std::string name) { json sourceSettings = config::config["sourceSettings"][name]; - // Set sample rate - - spdlog::warn("Type {0}", sourceSettings.contains("sampleRate")); - sampleRate = sourceSettings["sampleRate"]; - auto _srIt = std::find(soapy.sampleRates.begin(), soapy.sampleRates.end(), sampleRate); // If the sample rate isn't valid, set to minimum @@ -90,7 +85,7 @@ void loadSourceConfig(std::string name) { soapy.setSampleRate(sampleRate); // Set gains - delete uiGains; + delete[] uiGains; uiGains = new float[soapy.gainList.size()]; int i = 0; for (std::string gainName : soapy.gainList) { @@ -531,8 +526,15 @@ void drawWindow() { } ImGui::SameLine(); + bool noDevice = (soapy.devList.size() == 0); if (ImGui::Button("Refresh", ImVec2(menuColumnWidth - ImGui::GetCursorPosX(), 0.0f))) { soapy.refresh(); + if (noDevice && soapy.devList.size() > 0) { + soapy.setDevice(soapy.devList[0]); + if (config::config["sourceSettings"][soapy.devNameList[0]]) { + loadSourceConfig(soapy.devNameList[0]); + } + } } if (playing) { style::endDisabled(); }; @@ -563,10 +565,6 @@ void drawWindow() { config::configModified = true; } ImGui::PopItemWidth(); - - if (uiGains[i] != soapy.currentGains[i]) { - - } } ImGui::Spacing();