git: f788ec6d2e36 - main - cad/PrusaSlicer: backport fix from upstream

From: Michael Zhilin <mizhka_at_FreeBSD.org>
Date: Sat, 03 Dec 2022 07:05:56 UTC
The branch main has been updated by mizhka (src committer):

URL: https://cgit.FreeBSD.org/ports/commit/?id=f788ec6d2e3641a01e2207a207a797463a72b28a

commit f788ec6d2e3641a01e2207a207a797463a72b28a
Author:     Michael Zhilin <mizhka@FreeBSD.org>
AuthorDate: 2022-12-03 06:59:56 +0000
Commit:     Michael Zhilin <mizhka@FreeBSD.org>
CommitDate: 2022-12-03 07:05:30 +0000

    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
---
 cad/PrusaSlicer/Makefile                           | 21 ++++++++++----
 .../files/patch-src_slic3r_GUI_GUI__App.cpp        | 32 ++++++++++++++++++++--
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/cad/PrusaSlicer/Makefile b/cad/PrusaSlicer/Makefile
index 8b94985334b7..92e0df80a298 100644
--- a/cad/PrusaSlicer/Makefile
+++ b/cad/PrusaSlicer/Makefile
@@ -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=	*
 
diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_GUI__App.cpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_GUI__App.cpp
index 16c1ad89dcd4..1fa790d4d704 100644
--- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_GUI__App.cpp
+++ b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_GUI__App.cpp
@@ -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
  		}