[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.
This commit is contained in:
Adriaan de Groot 2024-02-27 00:28:36 +01:00
parent 9925d6666f
commit c4e0456acc

View File

@ -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();
}