Skip to content

Commit

Permalink
Fix of 8299 (Linux crash when selecting locales)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmatena committed May 26, 2022
1 parent d7105da commit ec6192a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,15 +1948,17 @@ static const wxLanguageInfo* linux_get_existing_locale_language(const wxLanguage
}),
locales.end());

// Is there a candidate matching a country code of a system language? Move it to the end,
// while maintaining the order of matches, so that the best match ends up at the very end.
std::string system_country = "_" + into_u8(system_language->CanonicalName.AfterFirst('_')).substr(0, 2);
int cnt = locales.size();
for (int i=0; i<cnt; ++i)
if (locales[i].find(system_country) != std::string::npos) {
locales.emplace_back(std::move(locales[i]));
locales[i].clear();
}
if (system_language) {
// Is there a candidate matching a country code of a system language? Move it to the end,
// while maintaining the order of matches, so that the best match ends up at the very end.
std::string system_country = "_" + into_u8(system_language->CanonicalName.AfterFirst('_')).substr(0, 2);
int cnt = locales.size();
for (int i=0; i<cnt; ++i)
if (locales[i].find(system_country) != std::string::npos) {
locales.emplace_back(std::move(locales[i]));
locales[i].clear();
}
}

// Now try them one by one.
for (auto it = locales.rbegin(); it != locales.rend(); ++ it)
Expand Down

0 comments on commit ec6192a

Please sign in to comment.