From 34c0cc5c6326918a33ae054cfc15a46b76255c14 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Thu, 15 Jun 2023 09:46:21 +0800 Subject: [PATCH] ENH: add some code to avoid crash in linux Change-Id: Ia82c05b0a7e16f8eb16fd5b3ff502ef1d7337291 Signed-off-by: Stone Li --- src/slic3r/GUI/GUI_App.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index cb5ef75072..9eff850f75 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -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