From 8bdf16fc3299ee1a8f1081a6ca11798c24cabf05 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 25 Aug 2022 12:34:25 +0200 Subject: [PATCH] Pref Controller: prevent loop with empty name in 'Save as ...' dialog --- src/controllers/dlgprefcontroller.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index 51f675a7798f..8854b7e6bc6e 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -649,6 +649,11 @@ void DlgPrefController::savePreset() { newFilePath = oldFilePath; } else { presetName = askForPresetName(presetName); + if (presetName.isEmpty()) { + // QInputDialog was closed + qDebug() << "Mapping not saved, new name is empty"; + return; + } newFilePath = presetNameToPath(m_pUserDir, presetName); m_pPreset->setName(presetName); qDebug() << "Mapping renamed to" << m_pPreset->name(); @@ -697,7 +702,8 @@ QString DlgPrefController::askForPresetName(const QString& prefilledName) const .remove(rxRemove) .trimmed(); if (!ok) { - continue; + // Return empty string if the dialog was canceled. Callers will deal with this. + return QString(); } if (presetName.isEmpty()) { QMessageBox::warning(nullptr,