From d59011f6dacee2190432dccf8372a6456d90c495 Mon Sep 17 00:00:00 2001 From: Be Date: Fri, 22 Oct 2021 12:26:14 -0500 Subject: [PATCH] DlgPrefEffects: fix preset removed from list when canceling delete fixes https://bugs.launchpad.net/mixxx/+bug/1947922 --- src/effects/presets/effectchainpresetmanager.cpp | 9 +++++---- src/effects/presets/effectchainpresetmanager.h | 2 +- src/preferences/dialog/dlgprefeffects.cpp | 7 +++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/effects/presets/effectchainpresetmanager.cpp b/src/effects/presets/effectchainpresetmanager.cpp index 70d046fd7d9..2b916858444 100644 --- a/src/effects/presets/effectchainpresetmanager.cpp +++ b/src/effects/presets/effectchainpresetmanager.cpp @@ -294,9 +294,9 @@ void EffectChainPresetManager::renamePreset(const QString& oldName) { emit effectChainPresetListUpdated(); } -void EffectChainPresetManager::deletePreset(const QString& chainPresetName) { +bool EffectChainPresetManager::deletePreset(const QString& chainPresetName) { VERIFY_OR_DEBUG_ASSERT(m_effectChainPresets.contains(chainPresetName)) { - return; + return false; } auto pressedButton = QMessageBox::question(nullptr, tr("Remove effect chain preset"), @@ -304,7 +304,7 @@ void EffectChainPresetManager::deletePreset(const QString& chainPresetName) { "\"%1\"?") .arg(chainPresetName)); if (pressedButton != QMessageBox::Yes) { - return; + return false; } QFile file(m_pConfig->getSettingsPath() + kEffectChainPresetDirectory + @@ -318,7 +318,7 @@ void EffectChainPresetManager::deletePreset(const QString& chainPresetName) { msgBox.setDetailedText(file.errorString()); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); - return; + return false; } EffectChainPresetPointer pPreset = @@ -327,6 +327,7 @@ void EffectChainPresetManager::deletePreset(const QString& chainPresetName) { m_quickEffectChainPresetsSorted.removeAll(pPreset); emit effectChainPresetListUpdated(); emit quickEffectChainPresetListUpdated(); + return true; } void EffectChainPresetManager::setPresetOrder( diff --git a/src/effects/presets/effectchainpresetmanager.h b/src/effects/presets/effectchainpresetmanager.h index 3a477392603..73948699c57 100644 --- a/src/effects/presets/effectchainpresetmanager.h +++ b/src/effects/presets/effectchainpresetmanager.h @@ -54,7 +54,7 @@ class EffectChainPresetManager : public QObject { void importPreset(); void exportPreset(const QString& chainPresetName); void renamePreset(const QString& oldName); - void deletePreset(const QString& chainPresetName); + bool deletePreset(const QString& chainPresetName); void resetToDefaults(); diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 713b10df4cd..26442cf03d2 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -283,9 +283,12 @@ void DlgPrefEffects::slotDeletePreset() { for (const auto& index : selectedIndices) { QString selectedPresetName = m_pFocusedChainList->model()->data(index).toString(); - focusedChainStringList.removeAll(selectedPresetName); if (!unfocusedChainStringList.contains(selectedPresetName)) { - m_pChainPresetManager->deletePreset(selectedPresetName); + if (m_pChainPresetManager->deletePreset(selectedPresetName)) { + focusedChainStringList.removeAll(selectedPresetName); + } + } else { + focusedChainStringList.removeAll(selectedPresetName); } }