From c4e0456accdee9de3af4752b64403174a5711970 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 27 Feb 2024 00:28:36 +0100 Subject: [PATCH] [locale] avoid crash when there are no good locales If the running locale doesn't match any locale in the list, nothing is selected. Avoid a crash when referring to first() of an empty list. --- src/modules/locale/LCLocaleDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/locale/LCLocaleDialog.cpp b/src/modules/locale/LCLocaleDialog.cpp index 1b6d6aaf9..4079d79b0 100644 --- a/src/modules/locale/LCLocaleDialog.cpp +++ b/src/modules/locale/LCLocaleDialog.cpp @@ -84,5 +84,6 @@ LCLocaleDialog::LCLocaleDialog( const QString& guessedLCLocale, const QStringLis QString LCLocaleDialog::selectedLCLocale() { - return m_localesWidget->selectedItems().first()->text(); + const auto items = m_localesWidget->selectedItems(); + return items.isEmpty() ? QString{} : items.first()->text(); }