ENH: add some code to avoid crash in linux

Change-Id: Ia82c05b0a7e16f8eb16fd5b3ff502ef1d7337291
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2023-06-15 09:46:21 +08:00 committed by Lane.Wei
parent a66c2d6d13
commit 34c0cc5c63

View file

@ -4745,7 +4745,11 @@ static const wxLanguageInfo* linux_get_existing_locale_language(const wxLanguage
// 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);
std::string temp_local = into_u8(system_language->CanonicalName.AfterFirst('_'));
if (temp_local.size() >= 2) {
temp_local = temp_local.substr(0, 2);
}
std::string system_country = "_" + temp_local;
int cnt = locales.size();
for (int i=0; i<cnt; ++i)
if (locales[i].find(system_country) != std::string::npos) {