Fix of #8299 (Linux crash when selecting locales)

This commit is contained in:
Lukas Matena 2022-05-26 10:11:49 +02:00
parent 7fbaf0f96c
commit c99de065f7

View file

@ -1962,15 +1962,17 @@ static const wxLanguageInfo* linux_get_existing_locale_language(const wxLanguage
}), }),
locales.end()); locales.end());
// Is there a candidate matching a country code of a system language? Move it to the end, if (system_language) {
// while maintaining the order of matches, so that the best match ends up at the very end. // Is there a candidate matching a country code of a system language? Move it to the end,
std::string system_country = "_" + into_u8(system_language->CanonicalName.AfterFirst('_')).substr(0, 2); // while maintaining the order of matches, so that the best match ends up at the very end.
int cnt = locales.size(); std::string system_country = "_" + into_u8(system_language->CanonicalName.AfterFirst('_')).substr(0, 2);
for (int i=0; i<cnt; ++i) int cnt = locales.size();
if (locales[i].find(system_country) != std::string::npos) { for (int i=0; i<cnt; ++i)
locales.emplace_back(std::move(locales[i])); if (locales[i].find(system_country) != std::string::npos) {
locales[i].clear(); locales.emplace_back(std::move(locales[i]));
} locales[i].clear();
}
}
// Now try them one by one. // Now try them one by one.
for (auto it = locales.rbegin(); it != locales.rend(); ++ it) for (auto it = locales.rbegin(); it != locales.rend(); ++ it)