superslicer: fix crash on start

This commit is contained in:
Gerasim Troeglazov
2025-06-11 19:23:33 +10:00
parent 0bbee20e80
commit 202f4cbb3f
2 changed files with 179 additions and 185 deletions

View File

@@ -1,6 +1,6 @@
From 9cc06c442e40499988b15302d00154b59760c3c3 Mon Sep 17 00:00:00 2001
From fbd091e5cffdc20b70bc999d9481bc1b70672585 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 8 Mar 2025 00:05:18 +1000
Date: Wed, 11 Jun 2025 18:48:53 +1000
Subject: Fixes for Haiku
@@ -491,9 +491,125 @@ index a7467fc..bb813f2 100644
# Some Linuxes may have very old libpng, so it's best to bundle it instead of relying on the system version.
diff --git a/haiku/GCodeViewer.cpp b/haiku/GCodeViewer.cpp
new file mode 100644
index 0000000..1977f47
index 0000000..dcd6876
--- /dev/null
+++ b/haiku/GCodeViewer.cpp
@@ -0,0 +1,110 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <OS.h>
+#include <Application.h>
+#include <String.h>
+#include <Resources.h>
+#include <Roster.h>
+#include <Path.h>
+#include <AppFileInfo.h>
+#include <kernel/image.h>
+
+class SuperSlicerLauncherApp : public BApplication {
+ public:
+ SuperSlicerLauncherApp(const char *signature, int argc, char **argv);
+ ~SuperSlicerLauncherApp() {};
+ void RefsReceived(BMessage *pmsg);
+ virtual void ReadyToRun();
+ BString GetApplicationPath(void);
+ private:
+ BMessenger fTrackerMessenger;
+};
+
+SuperSlicerLauncherApp::SuperSlicerLauncherApp(const char *signature, int argc, char **argv)
+ : BApplication(signature)
+{
+}
+
+BString
+SuperSlicerLauncherApp::GetApplicationPath(void)
+{
+ BPath path;
+ int32 cookie = 0;
+ image_info info;
+ while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+ if (info.type == B_APP_IMAGE) {
+ path.SetTo(info.name);
+ path.GetParent(&path);
+ break;
+ }
+ }
+ return path.Path();
+}
+
+void
+SuperSlicerLauncherApp::RefsReceived(BMessage *pmsg)
+{
+ if (pmsg->HasMessenger("TrackerViewToken")) {
+ pmsg->FindMessenger("TrackerViewToken", &fTrackerMessenger);
+ }
+
+ uint32 type;
+ int32 count;
+ status_t ret = pmsg->GetInfo("refs", &type, &count);
+ if (ret != B_OK || type != B_REF_TYPE)
+ return;
+
+ BString commandLine;
+ commandLine += "XDG_RUNTIME_DIR=/tmp ";
+ commandLine += "LD_PRELOAD=";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/lib/libfakelocaltime.so ";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/SuperSlicer";
+ commandLine += " --gcodeviewer";
+
+ entry_ref ref;
+ for (int32 i = 0; i < count; i++) {
+ if (pmsg->FindRef("refs", i, &ref) == B_OK)
+ {
+ BPath file = BPath(&ref);
+ commandLine += " \"";
+ commandLine += file.Path();
+ commandLine += "\"";
+ }
+ }
+ commandLine += " &";
+
+ system(commandLine.String());
+
+ Quit();
+}
+
+void
+SuperSlicerLauncherApp::ReadyToRun()
+{
+ BString commandLine;
+ commandLine += "XDG_RUNTIME_DIR=/tmp ";
+ commandLine += "LD_PRELOAD=";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/lib/libfakelocaltime.so ";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/SuperSlicer";
+ commandLine += " --gcodeviewer";
+ commandLine += " &";
+
+ system(commandLine.String());
+
+ Quit();
+}
+
+
+int main(int argc, char **argv)
+{
+ SuperSlicerLauncherApp application("application/x-vnd.superslicer-viewer-launcher", argc, argv);
+ application.Run();
+ return 0;
+}
diff --git a/haiku/SuperSlicer.cpp b/haiku/SuperSlicer.cpp
new file mode 100644
index 0000000..6addd6e
--- /dev/null
+++ b/haiku/SuperSlicer.cpp
@@ -0,0 +1,108 @@
+#include <stdlib.h>
+#include <stdio.h>
@@ -555,120 +671,7 @@ index 0000000..1977f47
+ return;
+
+ BString commandLine;
+ commandLine += "LD_PRELOAD=";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/lib/libfakelocaltime.so ";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/SuperSlicer";
+ commandLine += " --gcodeviewer";
+
+ entry_ref ref;
+ for (int32 i = 0; i < count; i++) {
+ if (pmsg->FindRef("refs", i, &ref) == B_OK)
+ {
+ BPath file = BPath(&ref);
+ commandLine += " \"";
+ commandLine += file.Path();
+ commandLine += "\"";
+ }
+ }
+ commandLine += " &";
+
+ system(commandLine.String());
+
+ Quit();
+}
+
+void
+SuperSlicerLauncherApp::ReadyToRun()
+{
+ BString commandLine;
+ commandLine += "LD_PRELOAD=";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/lib/libfakelocaltime.so ";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/SuperSlicer";
+ commandLine += " --gcodeviewer";
+ commandLine += " &";
+
+ system(commandLine.String());
+
+ Quit();
+}
+
+
+int main(int argc, char **argv)
+{
+ SuperSlicerLauncherApp application("application/x-vnd.superslicer-viewer-launcher", argc, argv);
+ application.Run();
+ return 0;
+}
diff --git a/haiku/SuperSlicer.cpp b/haiku/SuperSlicer.cpp
new file mode 100644
index 0000000..66660f4
--- /dev/null
+++ b/haiku/SuperSlicer.cpp
@@ -0,0 +1,106 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <OS.h>
+#include <Application.h>
+#include <String.h>
+#include <Resources.h>
+#include <Roster.h>
+#include <Path.h>
+#include <AppFileInfo.h>
+#include <kernel/image.h>
+
+class SuperSlicerLauncherApp : public BApplication {
+ public:
+ SuperSlicerLauncherApp(const char *signature, int argc, char **argv);
+ ~SuperSlicerLauncherApp() {};
+ void RefsReceived(BMessage *pmsg);
+ virtual void ReadyToRun();
+ BString GetApplicationPath(void);
+ private:
+ BMessenger fTrackerMessenger;
+};
+
+SuperSlicerLauncherApp::SuperSlicerLauncherApp(const char *signature, int argc, char **argv)
+ : BApplication(signature)
+{
+}
+
+BString
+SuperSlicerLauncherApp::GetApplicationPath(void)
+{
+ BPath path;
+ int32 cookie = 0;
+ image_info info;
+ while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+ if (info.type == B_APP_IMAGE) {
+ path.SetTo(info.name);
+ path.GetParent(&path);
+ break;
+ }
+ }
+ return path.Path();
+}
+
+void
+SuperSlicerLauncherApp::RefsReceived(BMessage *pmsg)
+{
+ if (pmsg->HasMessenger("TrackerViewToken")) {
+ pmsg->FindMessenger("TrackerViewToken", &fTrackerMessenger);
+ }
+
+ uint32 type;
+ int32 count;
+ status_t ret = pmsg->GetInfo("refs", &type, &count);
+ if (ret != B_OK || type != B_REF_TYPE)
+ return;
+
+ BString commandLine;
+ commandLine += "XDG_RUNTIME_DIR=/tmp ";
+ commandLine += "LD_PRELOAD=";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/lib/libfakelocaltime.so ";
@@ -696,6 +699,7 @@ index 0000000..66660f4
+SuperSlicerLauncherApp::ReadyToRun()
+{
+ BString commandLine;
+ commandLine += "XDG_RUNTIME_DIR=/tmp ";
+ commandLine += "LD_PRELOAD=";
+ commandLine += GetApplicationPath();
+ commandLine += "/bin/lib/libfakelocaltime.so ";
@@ -986,6 +990,53 @@ index 3387521..72fe64e 100644
BOOST_LOG_TRIVIAL(info) << "Platform: OpenBSD";
s_platform = Platform::BSDUnix;
s_platform_flavor = PlatformFlavor::OpenBSD;
diff --git a/src/libslic3r/Thread.cpp b/src/libslic3r/Thread.cpp
index 6f5efda..33bb3b5 100644
--- a/src/libslic3r/Thread.cpp
+++ b/src/libslic3r/Thread.cpp
@@ -6,6 +6,10 @@
#include <pthread.h>
#endif
+#ifdef __HAIKU__
+#include <OS.h>
+#endif
+
#include <atomic>
#include <condition_variable>
#include <mutex>
@@ -157,6 +161,31 @@ std::optional<std::string> get_current_thread_name()
return std::nullopt;
}
+#elif defined(__HAIKU__)
+
+bool set_thread_name(std::thread &thread, const char *thread_name)
+{
+ return rename_thread(get_pthread_thread_id(thread.native_handle()), thread_name) == B_OK;
+}
+
+bool set_thread_name(boost::thread &thread, const char *thread_name)
+{
+ return rename_thread(get_pthread_thread_id(thread.native_handle()), thread_name) == B_OK;
+}
+
+bool set_current_thread_name(const char *thread_name)
+{
+ return rename_thread(find_thread(NULL), thread_name) == B_OK;
+}
+
+std::optional<std::string> get_current_thread_name()
+{
+ thread_info info;
+ if (get_thread_info(find_thread(NULL), &info) == B_OK)
+ return std::string(info.name);
+ return std::string("");
+}
+
#else
// posix
diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp
index 6eac962..070a581 100644
--- a/src/libslic3r/utils.cpp
@@ -1272,60 +1323,3 @@ index 4db1acc..ac96361 100644
--
2.48.1
From 6b5ed8503f6d5d4bf761658279e912ed13e7db8c Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 8 Mar 2025 11:46:27 +1000
Subject: Implement set_thread_name for Haiku
diff --git a/src/libslic3r/Thread.cpp b/src/libslic3r/Thread.cpp
index 6f5efda..33bb3b5 100644
--- a/src/libslic3r/Thread.cpp
+++ b/src/libslic3r/Thread.cpp
@@ -6,6 +6,10 @@
#include <pthread.h>
#endif
+#ifdef __HAIKU__
+#include <OS.h>
+#endif
+
#include <atomic>
#include <condition_variable>
#include <mutex>
@@ -157,6 +161,31 @@ std::optional<std::string> get_current_thread_name()
return std::nullopt;
}
+#elif defined(__HAIKU__)
+
+bool set_thread_name(std::thread &thread, const char *thread_name)
+{
+ return rename_thread(get_pthread_thread_id(thread.native_handle()), thread_name) == B_OK;
+}
+
+bool set_thread_name(boost::thread &thread, const char *thread_name)
+{
+ return rename_thread(get_pthread_thread_id(thread.native_handle()), thread_name) == B_OK;
+}
+
+bool set_current_thread_name(const char *thread_name)
+{
+ return rename_thread(find_thread(NULL), thread_name) == B_OK;
+}
+
+std::optional<std::string> get_current_thread_name()
+{
+ thread_info info;
+ if (get_thread_info(find_thread(NULL), &info) == B_OK)
+ return std::string(info.name);
+ return std::string("");
+}
+
#else
// posix
--
2.48.1

View File

@@ -25,23 +25,23 @@ What are SuperSlicer main features? main new features/differences?
HOMEPAGE="https://github.com/supermerill/SuperSlicer"
COPYRIGHT="Merill"
LICENSE="GNU AGPL v3"
REVISION="2"
REVISION="3"
SOURCE_URI="https://github.com/supermerill/SuperSlicer/archive/refs/tags/$portVersion.tar.gz"
CHECKSUM_SHA256="47ddf0dcf2d428e483011a74d32fe56a75fbe55dc8a3187956d5dd5758279dcb"
SOURCE_DIR="SuperSlicer-$portVersion"
PATCHES="superslicer-$portVersion.patchset"
srcGitRev2="fe18f18b4c005a2c4e4b69a5866d0d065bde82aa"
SOURCE_URI_2="https://github.com/FormerLurker/ArcWelderLib/archive/$srcGitRev2.zip"
CHECKSUM_SHA256_2="52792a9c48b38aca81dc7eb3aae8d7ace9abc93c6c43ba18e1ed5abc96c71362"
SOURCE_URI_2="https://github.com/FormerLurker/ArcWelderLib/archive/$srcGitRev2.tar.gz"
CHECKSUM_SHA256_2="c38a02ab3d7e5da05402e0c9ecaabc70e576e60b0b93b8f0b7b78f456113e60d"
SOURCE_DIR_2="ArcWelderLib-$srcGitRev2"
srcGitRev3="ca25c7ec55dcc6073da61e39692c321cdb6497dc"
SOURCE_URI_3="https://github.com/slic3r/slic3r-profiles/archive/$srcGitRev3.zip"
CHECKSUM_SHA256_3="4c9f792e1e09b6edd7cba35198b7d34e38d9243a0dda742cc0c238cb0ae9d74b"
SOURCE_URI_3="https://github.com/slic3r/slic3r-profiles/archive/$srcGitRev3.tar.gz"
CHECKSUM_SHA256_3="01ed3cada426e586960338ddb63c8113c86b698d4d6debdabaa720463bbdbb98"
SOURCE_DIR_3="slic3r-profiles-$srcGitRev3"
srcGitRev4="a7eb2cfd53a70fcd9ba9dcfad80a3994642f362f"
SOURCE_URI_4="https://gitlab.freedesktop.org/mesa/drm/-/archive/$srcGitRev4/drm-$srcGitRev4.tar.gz"
CHECKSUM_SHA256_4="f34af06cd3d7c0b8b68b8bbe9844d02114bd19a1a7eab7520c2f7fbd0956cbb5"
SOURCE_DIR_4="drm-$srcGitRev4"
CHECKSUM_SHA256_4="c62ee1655e6beee0f876ee9b91e3f273d76827b322c29d2940cb6b95ee03a192"
SOURCE_DIR_4="libdrm-$srcGitRev4"
PATCHES_4="superslicer-$portVersion-drm.patchset"
srcGitRev5="37a38f6744f3e81063d13995a974ccd383050514"
SOURCE_URI_5="https://gitlab.freedesktop.org/mesa/mesa/-/archive/$srcGitRev5/mesa-$srcGitRev5.tar.bz2"
@@ -99,7 +99,7 @@ REQUIRES="
lib:libharfbuzz$secondaryArchSuffix
lib:libintl$secondaryArchSuffix
lib:libjpeg$secondaryArchSuffix
lib:libLLVM$secondaryArchSuffix >= 18
lib:libLLVM$secondaryArchSuffix >= 20
lib:libmpfr$secondaryArchSuffix
lib:libnlopt$secondaryArchSuffix
lib:libpango_1.0$secondaryArchSuffix
@@ -153,7 +153,7 @@ BUILD_REQUIRES="
devel:libgtk_3$secondaryArchSuffix
devel:libhalf_2_4$secondaryArchSuffix
devel:libintl$secondaryArchSuffix
devel:libLLVM_18$secondaryArchSuffix
devel:libLLVM_20$secondaryArchSuffix
devel:libjpeg$secondaryArchSuffix
devel:libnettle$secondaryArchSuffix
devel:libnghttp2$secondaryArchSuffix
@@ -196,8 +196,8 @@ BUILD_PREREQUIRES="
cmd:git
cmd:libtoolize$secondaryArchSuffix
cmd:ld$secondaryArchSuffix
cmd:lld >= 18
cmd:llvm_config >= 18
cmd:lld >= 20
cmd:llvm_config >= 20
cmd:make
cmd:makeinfo
cmd:meson