Initialize locale before wxTranslations::Get()

This fixes a crash similar to <https://github.com/prusa3d/PrusaSlicer/issues/8299>.
This commit is contained in:
Zhaofeng Li 2023-06-07 19:15:51 -06:00 committed by Lane.Wei
parent 2bca1fc9f3
commit 693af0c98f
1 changed files with 1 additions and 0 deletions

View File

@ -4766,6 +4766,7 @@ bool GUI_App::load_language(wxString language, bool initial)
{
// Allocating a temporary locale will switch the default wxTranslations to its internal wxTranslations instance.
wxLocale temp_locale;
temp_locale.Init();
// Set the current translation's language to default, otherwise GetBestTranslation() may not work (see the wxWidgets source code).
wxTranslations::Get()->SetLanguage(wxLANGUAGE_DEFAULT);
// Let the wxFileTranslationsLoader enumerate all translation dictionaries for PrusaSlicer