Skip to content

Commit

Permalink
Pref Controller: prevent loop with empty name in 'Save as ...' dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Aug 25, 2022
1 parent e2671b7 commit 8bdf16f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8bdf16f

Please sign in to comment.