Fixed delete[] in soapy.h

This commit is contained in:
Ryzerth 2020-08-16 18:18:10 +02:00
parent 03dc5d2042
commit b2191c5d2c

View File

@ -70,13 +70,8 @@ void saveCurrentSource() {
void loadSourceConfig(std::string name) { void loadSourceConfig(std::string name) {
json sourceSettings = config::config["sourceSettings"][name]; json sourceSettings = config::config["sourceSettings"][name];
// Set sample rate
spdlog::warn("Type {0}", sourceSettings.contains("sampleRate"));
sampleRate = sourceSettings["sampleRate"]; sampleRate = sourceSettings["sampleRate"];
auto _srIt = std::find(soapy.sampleRates.begin(), soapy.sampleRates.end(), sampleRate); auto _srIt = std::find(soapy.sampleRates.begin(), soapy.sampleRates.end(), sampleRate);
// If the sample rate isn't valid, set to minimum // If the sample rate isn't valid, set to minimum
if (_srIt == soapy.sampleRates.end()) { if (_srIt == soapy.sampleRates.end()) {
@ -90,7 +85,7 @@ void loadSourceConfig(std::string name) {
soapy.setSampleRate(sampleRate); soapy.setSampleRate(sampleRate);
// Set gains // Set gains
delete uiGains; delete[] uiGains;
uiGains = new float[soapy.gainList.size()]; uiGains = new float[soapy.gainList.size()];
int i = 0; int i = 0;
for (std::string gainName : soapy.gainList) { for (std::string gainName : soapy.gainList) {
@ -531,8 +526,15 @@ void drawWindow() {
} }
ImGui::SameLine(); ImGui::SameLine();
bool noDevice = (soapy.devList.size() == 0);
if (ImGui::Button("Refresh", ImVec2(menuColumnWidth - ImGui::GetCursorPosX(), 0.0f))) { if (ImGui::Button("Refresh", ImVec2(menuColumnWidth - ImGui::GetCursorPosX(), 0.0f))) {
soapy.refresh(); 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(); }; if (playing) { style::endDisabled(); };
@ -563,10 +565,6 @@ void drawWindow() {
config::configModified = true; config::configModified = true;
} }
ImGui::PopItemWidth(); ImGui::PopItemWidth();
if (uiGains[i] != soapy.currentGains[i]) {
}
} }
ImGui::Spacing(); ImGui::Spacing();