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 4c732ac commit 8fa2c5d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ void DlgPrefController::saveMapping() {
newFilePath = oldFilePath;
} else {
mappingName = askForMappingName(mappingName);
if (mappingName.isEmpty()) {
// QInputDialog was closed
return;
}
newFilePath = mappingNameToPath(m_pUserDir, mappingName);
m_pMapping->setName(mappingName);
qDebug() << "Mapping renamed to" << m_pMapping->name();
Expand Down Expand Up @@ -727,8 +731,9 @@ QString DlgPrefController::askForMappingName(const QString& prefilledName) const
&ok)
.remove(rxRemove)
.trimmed();
// Return empty string if the dialog was canceled. Callers will deal with this.
if (!ok) {
continue;
return QString();
}
if (mappingName.isEmpty()) {
QMessageBox::warning(nullptr,
Expand Down

0 comments on commit 8fa2c5d

Please sign in to comment.