From af7084def76ffc9e859a720816518bcb6601aa88 Mon Sep 17 00:00:00 2001 From: Hanan V Date: Fri, 23 Oct 2026 07:45:26 +0700 Subject: [PATCH] Fix a crash slicing painted objects: two classes named Slic3r::IslandLocator (#16774) #15985 added a file-local IslandLocator class to MultiMaterialSegmentation.cpp, and #16291 added a different Slic3r::IslandLocator in ConnectedBodies.hpp. Their implicit destructors have the same symbol, so the linker keeps only one of them. When it keeps the ConnectedBodies one, merge_segmented_layers destroys its locator with the wrong destructor and frees memory it never allocated. On builds where that destructor is not inlined, slicing any painted object crashes. Put the MultiMaterialSegmentation class in an unnamed namespace so it is private to its file. --- src/libslic3r/MultiMaterialSegmentation.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index 507d997f1d..4c32c7380a 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -1928,6 +1928,7 @@ static void remove_multiple_edges_in_vertices(MMU_Graph &graph, const std::vecto } +namespace { // Finds the islands (layer ExPolygons) a region piece overlaps. A top or bottom region is projected from the neighbouring // layers and may reach past the island it belongs to, or over several islands. class IslandLocator @@ -1987,6 +1988,7 @@ private: coord_t m_cell_w = 1, m_cell_h = 1; std::vector> m_grid; }; +} // namespace static std::vector> merge_segmented_layers(const std::vector &input_expolygons, const std::vector> &segmented_regions,