1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-08 06:48:28 +00:00

cad/PrusaSlicer: backport fix from upstream

- The app is crashing when tries to set default language.
 - Make QA tests a bit more happy

PR: 267883
Submitted by: michal.zielonka.8001@gmail.com
This commit is contained in:
Michael Zhilin 2022-12-03 09:59:56 +03:00
parent 204a90044d
commit f788ec6d2e
2 changed files with 46 additions and 7 deletions

View File

@ -1,4 +1,5 @@
PORTNAME= PrusaSlicer
PORTREVISION= 1
DISTVERSIONPREFIX=version_
DISTVERSION= 2.5.0
CATEGORIES= cad
@ -23,17 +24,27 @@ LIB_DEPENDS= libtbb.so:devel/onetbb \
libgmp.so:math/gmp \
libmpfr.so:math/mpfr \
libdbus-1.so:devel/dbus \
libpng.so:graphics/png
libpng.so:graphics/png \
libTKXDESTEP.so:cad/opencascade \
libtiff.so:graphics/tiff \
libfontconfig.so:x11-fonts/fontconfig \
libfreeimage.so:graphics/freeimage \
libfreetype.so:print/freetype2 \
libavcodec.so:multimedia/ffmpeg \
libharfbuzz.so:print/harfbuzz
USES= cmake cpe desktop-file-utils eigen:3 gettext gl iconv pkgconfig
USES= cmake cpe desktop-file-utils eigen:3 gettext gl pkgconfig jpeg iconv gnome xorg
CPE_VENDOR= prusa3d
CMAKE_ARGS+= -DwxWidgets_CONFIG_EXECUTABLE="${WX_CONFIG}" \
-DSLIC3R_GTK=3 \
-DSLIC3R_FHS=1
USE_GITHUB= yes
GH_ACCOUNT= prusa3d
USE_GL= gl glu glew
USE_GNOME= gtk30 pango atk cairo gdkpixbuf2 glib20
USE_WX= 3.2
USE_XORG= x11
CMAKE_ARGS+= -DwxWidgets_CONFIG_EXECUTABLE="${WX_CONFIG}" \
-DSLIC3R_GTK=3 \
-DSLIC3R_FHS=1
PORTDATA= *

View File

@ -1,6 +1,6 @@
--- src/slic3r/GUI/GUI_App.cpp.orig 2022-09-06 07:09:19 UTC
+++ src/slic3r/GUI/GUI_App.cpp
@@ -2072,7 +2072,7 @@ bool GUI_App::load_language(wxString language, bool in
@@ -2072,21 +2072,24 @@ bool GUI_App::load_language(wxString language, bool in
BOOST_LOG_TRIVIAL(trace) << boost::format("System language detected (user locales and such): %1%") % m_language_info_system->CanonicalName.ToUTF8().data();
}
}
@ -9,7 +9,35 @@
// Allocating a temporary locale will switch the default wxTranslations to its internal wxTranslations instance.
wxLocale temp_locale;
// Set the current translation's language to default, otherwise GetBestTranslation() may not work (see the wxWidgets source code).
@@ -2096,6 +2096,7 @@ bool GUI_App::load_language(wxString language, bool in
- wxTranslations::Get()->SetLanguage(wxLANGUAGE_DEFAULT);
- // Let the wxFileTranslationsLoader enumerate all translation dictionaries for PrusaSlicer
- // and try to match them with the system specific "preferred languages".
- // There seems to be a support for that on Windows and OSX, while on Linuxes the code just returns wxLocale::GetSystemLanguage().
- // The last parameter gets added to the list of detected dictionaries. This is a workaround
- // for not having the English dictionary. Let's hope wxWidgets of various versions process this call the same way.
- wxString best_language = wxTranslations::Get()->GetBestTranslation(SLIC3R_APP_KEY, wxLANGUAGE_ENGLISH);
- if (! best_language.IsEmpty()) {
- m_language_info_best = wxLocale::FindLanguageInfo(best_language);
- BOOST_LOG_TRIVIAL(trace) << boost::format("Best translation language detected (may be different from user locales): %1%") % m_language_info_best->CanonicalName.ToUTF8().data();
- }
+ wxTranslations *wx_trp = wxTranslations::Get();
+ if (wx_trp) {
+ wxTranslations::Get()->SetLanguage(wxLANGUAGE_DEFAULT);
+ // Let the wxFileTranslationsLoader enumerate all translation dictionaries for PrusaSlicer
+ // and try to match them with the system specific "preferred languages".
+ // There seems to be a support for that on Windows and OSX, while on Linuxes the code just returns wxLocale::GetSystemLanguage().
+ // The last parameter gets added to the list of detected dictionaries. This is a workaround
+ // for not having the English dictionary. Let's hope wxWidgets of various versions process this call the same way.
+ wxString best_language = wxTranslations::Get()->GetBestTranslation(SLIC3R_APP_KEY, wxLANGUAGE_ENGLISH);
+ if (! best_language.IsEmpty()) {
+ m_language_info_best = wxLocale::FindLanguageInfo(best_language);
+ BOOST_LOG_TRIVIAL(trace) << boost::format("Best translation language detected (may be different from user locales): %1%") % m_language_info_best->CanonicalName.ToUTF8().data();
+ }
+ }
#ifdef __linux__
wxString lc_all;
if (wxGetEnv("LC_ALL", &lc_all) && ! lc_all.IsEmpty()) {
@@ -2096,6 +2099,7 @@ bool GUI_App::load_language(wxString language, bool in
}
#endif
}