commit:     318c82dd47bb625f131cfac6bb04b91542e4506e
Author:     Piotr Karbowski <slashbeast <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 22 18:02:15 2023 +0000
Commit:     Piotr Karbowski <slashbeast <AT> gentoo <DOT> org>
CommitDate: Sat Apr 22 18:09:11 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=318c82dd

media-gfx/superslicer: 2.5.59.2-r1 revbump

- Fixes crash on enabling vase mode (superslicer PR #3736
- Links bundled OCCTWrapper statically
- Fix unique_ptr null pointer crash on slicing
- Adds missing dependency on OpenCASCADE

Closes: https://bugs.gentoo.org/904558
Closes: https://bugs.gentoo.org/904656
Closes: https://bugs.gentoo.org/904727
Bug: https://github.com/supermerill/SuperSlicer/issues/3731
Signed-off-by: Piotr Karbowski <slashbeast <AT> gentoo.org>

 ...ereferencing-in-std-unique_ptr-to-nullptr.patch | 82 +++++++++++++++++++
 ...cer-2.5.59.2-fix-spiral_vase-null-pointer.patch | 22 +++++
 ...icer-2.5.59.2-link-occtwrapper-statically.patch | 93 ++++++++++++++++++++++
 ....59.2.ebuild => superslicer-2.5.59.2-r1.ebuild} |  4 +
 4 files changed, 201 insertions(+)

diff --git 
a/media-gfx/superslicer/files/superslicer-2.5.59.2-fix-dereferencing-in-std-unique_ptr-to-nullptr.patch
 
b/media-gfx/superslicer/files/superslicer-2.5.59.2-fix-dereferencing-in-std-unique_ptr-to-nullptr.patch
new file mode 100644
index 000000000000..4e93fca55e08
--- /dev/null
+++ 
b/media-gfx/superslicer/files/superslicer-2.5.59.2-fix-dereferencing-in-std-unique_ptr-to-nullptr.patch
@@ -0,0 +1,82 @@
+diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp
+index 68ec2ce..cd828a6 100644
+--- a/src/libslic3r/GCode.cpp
++++ b/src/libslic3r/GCode.cpp
+@@ -2081,31 +2081,30 @@ void GCode::process_layers(
+             }
+         });
+     const auto spiral_vase = tbb::make_filter<LayerResult, 
LayerResult>(slic3r_tbb_filtermode::serial_in_order,
+-        [&spiral_vase = *this->m_spiral_vase](LayerResult in) -> LayerResult {
++        [spiral_vase = this->m_spiral_vase.get()](LayerResult in) -> 
LayerResult {
+             if (in.nop_layer_result)
+                 return in;
+ 
+             CNumericLocalesSetter locales_setter;
+-            spiral_vase.enable(in.spiral_vase_enable);
+-            return LayerResult{ 
spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, 
in.spiral_vase_enable, in.cooling_buffer_flush };
++            spiral_vase->enable(in.spiral_vase_enable);
++            return { spiral_vase->process_layer(std::move(in.gcode)), 
in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush};
+         });
+     const auto pressure_equalizer = tbb::make_filter<LayerResult, 
LayerResult>(slic3r_tbb_filtermode::serial_in_order,
+-        [&pressure_equalizer = *this->m_pressure_equalizer](LayerResult in) 
-> LayerResult {
+-            return pressure_equalizer.process_layer(std::move(in));
++        [pressure_equalizer = this->m_pressure_equalizer.get()](LayerResult 
in) -> LayerResult {
++             return pressure_equalizer->process_layer(std::move(in));
+         });
+     const auto cooling = tbb::make_filter<LayerResult, 
std::string>(slic3r_tbb_filtermode::serial_in_order,
+-        [&cooling_buffer = *this->m_cooling_buffer](LayerResult in) -> 
std::string {
++        [cooling_buffer = this->m_cooling_buffer.get()](LayerResult 
in)->std::string {
+              if (in.nop_layer_result)
+                 return in.gcode;
+ 
+             CNumericLocalesSetter locales_setter;
+-            return cooling_buffer.process_layer(std::move(in.gcode), 
in.layer_id, in.cooling_buffer_flush);
++            return cooling_buffer->process_layer(std::move(in.gcode), 
in.layer_id, in.cooling_buffer_flush);
+         });
+     const auto find_replace = tbb::make_filter<std::string, 
std::string>(slic3r_tbb_filtermode::serial_in_order,
+-        [&self = *this->m_find_replace](std::string s) -> std::string {
+-            CNumericLocalesSetter locales_setter;
+-            return self.process_layer(std::move(s));
+-        });
++        [find_replace = this->m_find_replace.get()](std::string s) -> 
std::string {
++            return find_replace->process_layer(std::move(s));
++});
+     const auto output = tbb::make_filter<std::string, 
void>(slic3r_tbb_filtermode::serial_in_order,
+         [&output_stream](std::string s) {
+             CNumericLocalesSetter locales_setter;
+@@ -2183,25 +2182,26 @@ void GCode::process_layers(
+             }
+         });
+     const auto spiral_vase = tbb::make_filter<LayerResult, 
LayerResult>(slic3r_tbb_filtermode::serial_in_order,
+-        [&spiral_vase = *this->m_spiral_vase](LayerResult in)->LayerResult {
++       [spiral_vase = this->m_spiral_vase.get()](LayerResult in) -> 
LayerResult {
+             if (in.nop_layer_result)
+                 return in;
+-        spiral_vase.enable(in.spiral_vase_enable);
+-        return { spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, 
in.spiral_vase_enable, in.cooling_buffer_flush };
++            spiral_vase->enable(in.spiral_vase_enable);
++            return { spiral_vase->process_layer(std::move(in.gcode)), 
in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush};
+     });
+     const auto pressure_equalizer = tbb::make_filter<LayerResult, 
LayerResult>(slic3r_tbb_filtermode::serial_in_order,
+-        [&pressure_equalizer = *this->m_pressure_equalizer](LayerResult in) 
-> LayerResult {
+-             return pressure_equalizer.process_layer(std::move(in));
++        [pressure_equalizer = this->m_pressure_equalizer.get()](LayerResult 
in) -> LayerResult {
++            return pressure_equalizer->process_layer(std::move(in));
+         });
+     const auto cooling = tbb::make_filter<LayerResult, 
std::string>(slic3r_tbb_filtermode::serial_in_order,
+-        [&cooling_buffer = *this->m_cooling_buffer](LayerResult 
in)->std::string {
++        [cooling_buffer = this->m_cooling_buffer.get()](LayerResult in) -> 
std::string {
+             if (in.nop_layer_result)
+                 return in.gcode;
+-            return cooling_buffer.process_layer(std::move(in.gcode), 
in.layer_id, in.cooling_buffer_flush);
++             return cooling_buffer->process_layer(std::move(in.gcode), 
in.layer_id, in.cooling_buffer_flush);
++
+         });
+     const auto find_replace = tbb::make_filter<std::string, 
std::string>(slic3r_tbb_filtermode::serial_in_order,
+-        [&self = *this->m_find_replace](std::string s) -> std::string {
+-            return self.process_layer(std::move(s));
++        [find_replace = this->m_find_replace.get()](std::string s) -> 
std::string {
++            return find_replace->process_layer(std::move(s));
+         });
+     const auto output = tbb::make_filter<std::string, 
void>(slic3r_tbb_filtermode::serial_in_order,
+         [&output_stream](std::string s) { 

diff --git 
a/media-gfx/superslicer/files/superslicer-2.5.59.2-fix-spiral_vase-null-pointer.patch
 
b/media-gfx/superslicer/files/superslicer-2.5.59.2-fix-spiral_vase-null-pointer.patch
new file mode 100644
index 000000000000..4dcc7f54a444
--- /dev/null
+++ 
b/media-gfx/superslicer/files/superslicer-2.5.59.2-fix-spiral_vase-null-pointer.patch
@@ -0,0 +1,22 @@
+From 6461985380814b92aab1caa791bee75d94e68676 Mon Sep 17 00:00:00 2001
+From: Tim Schneider <[email protected]>
+Date: Sat, 18 Mar 2023 17:51:38 +0100
+Subject: [PATCH] Fix crash on spiral_vase.
+
+---
+ src/libslic3r/PrintConfig.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp
+index 05bc79e53b..8c74880260 100644
+--- a/src/libslic3r/PrintConfig.cpp
++++ b/src/libslic3r/PrintConfig.cpp
+@@ -8055,7 +8055,7 @@ void DynamicPrintConfig::normalize_fdm()
+         {
+             this->opt<ConfigOptionInt>("top_solid_layers", true)->value = 0;
+             this->opt<ConfigOptionPercent>("fill_density", true)->value = 0;
+-            
this->opt<ConfigOptionEnum<PerimeterGeneratorType>>("perimeter_generator", 
true)->value = PerimeterGeneratorType::Classic; 
++            
this->option<ConfigOptionEnum<PerimeterGeneratorType>>("perimeter_generator", 
true)->value = PerimeterGeneratorType::Classic; 
+             this->opt<ConfigOptionBool>("support_material", true)->value = 
false;
+             this->opt<ConfigOptionInt>("solid_over_perimeters")->value = 0;
+             
this->opt<ConfigOptionInt>("support_material_enforce_layers")->value = 0;

diff --git 
a/media-gfx/superslicer/files/superslicer-2.5.59.2-link-occtwrapper-statically.patch
 
b/media-gfx/superslicer/files/superslicer-2.5.59.2-link-occtwrapper-statically.patch
new file mode 100644
index 000000000000..bb5b51f82a66
--- /dev/null
+++ 
b/media-gfx/superslicer/files/superslicer-2.5.59.2-link-occtwrapper-statically.patch
@@ -0,0 +1,93 @@
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index b84292b..63fea9c 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -19,7 +19,7 @@ add_subdirectory(libnest2d)
+ add_subdirectory(libslic3r)
+ 
+ if (SLIC3R_ENABLE_FORMAT_STEP)
+-    add_subdirectory(occt_wrapper)
++    add_subdirectory(occt_wrapper EXCLUDE_FROM_ALL)
+ endif ()
+ 
+ if (SLIC3R_GUI)
+diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt
+index 36917f3..63c4201 100644
+--- a/src/libslic3r/CMakeLists.txt
++++ b/src/libslic3r/CMakeLists.txt
+@@ -435,10 +435,7 @@ target_link_libraries(libslic3r
+     qoi
+     )
+ 
+-if (APPLE)
+-    # TODO: we need to fix notarization with the separate shared library
+-    target_link_libraries(libslic3r OCCTWrapper)
+-endif ()
++target_link_libraries(libslic3r OCCTWrapper)
+ 
+ if (TARGET OpenVDB::openvdb)
+     target_link_libraries(libslic3r OpenVDB::openvdb)
+diff --git a/src/libslic3r/Format/STEP.cpp b/src/libslic3r/Format/STEP.cpp
+index 5165bb7..3ed0154 100644
+--- a/src/libslic3r/Format/STEP.cpp
++++ b/src/libslic3r/Format/STEP.cpp
+@@ -22,17 +22,13 @@
+ 
+ namespace Slic3r {
+ 
+-#if __APPLE__
+ extern "C" bool load_step_internal(const char *path, OCCTResult* res);
+-#endif
+ 
+ LoadStepFn get_load_step_fn()
+ {
+     static LoadStepFn load_step_fn = nullptr;
+ 
+-#ifndef __APPLE__
+     constexpr const char* fn_name = "load_step_internal";
+-#endif
+ 
+     if (!load_step_fn) {
+         auto libpath = boost::dll::program_location().parent_path();
+@@ -54,22 +50,8 @@ LoadStepFn get_load_step_fn()
+             FreeLibrary(module);
+             throw;
+         }
+-#elif __APPLE__
+-        load_step_fn = &load_step_internal;
+ #else
+-        libpath /= "OCCTWrapper.so";
+-        void *plugin_ptr = dlopen(libpath.c_str(), RTLD_NOW | RTLD_GLOBAL);
+-
+-        if (plugin_ptr) {
+-            load_step_fn = reinterpret_cast<LoadStepFn>(dlsym(plugin_ptr, 
fn_name));
+-            if (!load_step_fn) {
+-                dlclose(plugin_ptr);
+-                throw Slic3r::RuntimeError(std::string("Cannot load function 
from OCCTWrapper.so: ") + fn_name
+-                                           + "\n\n" + dlerror());
+-            }
+-        } else {
+-            throw Slic3r::RuntimeError(std::string("Cannot load 
OCCTWrapper.so:\n\n") + dlerror());
+-        }
++        load_step_fn = &load_step_internal;
+ #endif
+     }
+ 
+diff --git a/src/occt_wrapper/CMakeLists.txt b/src/occt_wrapper/CMakeLists.txt
+index 16de4e0..ad983be 100644
+--- a/src/occt_wrapper/CMakeLists.txt
++++ b/src/occt_wrapper/CMakeLists.txt
+@@ -1,12 +1,7 @@
+ cmake_minimum_required(VERSION 3.13)
+ project(OCCTWrapper)
+ 
+-if (APPLE)
+-    # TODO: we need to fix notarization with the separate shared library
+-    add_library(OCCTWrapper STATIC OCCTWrapper.cpp)
+-else ()
+-    add_library(OCCTWrapper MODULE OCCTWrapper.cpp)
+-endif ()
++add_library(OCCTWrapper STATIC OCCTWrapper.cpp)
+ 
+ set_target_properties(OCCTWrapper
+     PROPERTIES

diff --git a/media-gfx/superslicer/superslicer-2.5.59.2.ebuild 
b/media-gfx/superslicer/superslicer-2.5.59.2-r1.ebuild
similarity index 91%
rename from media-gfx/superslicer/superslicer-2.5.59.2.ebuild
rename to media-gfx/superslicer/superslicer-2.5.59.2-r1.ebuild
index 304f0fbf199c..c29633c2bc55 100644
--- a/media-gfx/superslicer/superslicer-2.5.59.2.ebuild
+++ b/media-gfx/superslicer/superslicer-2.5.59.2-r1.ebuild
@@ -40,6 +40,7 @@ RDEPEND="
        media-libs/libpng:0=
        media-libs/qhull:=
        sci-libs/nlopt
+       sci-libs/opencascade:=
        >=sci-mathematics/cgal-5.0:=
        sys-apps/dbus
        sys-libs/zlib:=
@@ -61,6 +62,9 @@ PATCHES=(
        "${FILESDIR}/${P}-openexr3.patch"
        "${FILESDIR}/${P}-wxgtk3-wayland-fix.patch"
        "${FILESDIR}/${P}-relax-OpenCASCADE-dep.patch"
+       "${FILESDIR}/${P}-link-occtwrapper-statically.patch"
+       "${FILESDIR}/${P}-fix-dereferencing-in-std-unique_ptr-to-nullptr.patch"
+       "${FILESDIR}/${P}-fix-spiral_vase-null-pointer.patch"
 )
 
 S="${WORKDIR}/${MY_PN}-${PV}"

Reply via email to