diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index c57e6fcfa86d..bdaadeced90d 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -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(); @@ -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,