From 7d31f8c0bae3ef8b0d572f4391839045730ebdfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Tue, 23 Jan 2024 12:33:19 +0100 Subject: [PATCH] SPE-2120: Fix another crash caused by using GCodeGenerator::last_position when it doesn't have an assigned value. This behavior was there for a long time, but it was uncovered when std::optional was used. --- src/libslic3r/GCode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 65fb8683e4..5a9253a8e4 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2767,8 +2767,9 @@ std::string GCodeGenerator::extrude_skirt( const GCode::SmoothPathCache &smooth_path_cache, const std::string_view description, double speed) { assert(loop_src.is_counter_clockwise()); + Point seam_point = this->last_position.has_value() ? *this->last_position : Point::Zero(); GCode::SmoothPath smooth_path = smooth_path_cache.resolve_or_fit_split_with_seam( - loop_src, false, m_scaled_resolution, *this->last_position, scaled(0.0015)); + loop_src, false, m_scaled_resolution, seam_point, scaled(0.0015)); // Clip the path to avoid the extruder to get exactly on the first point of the loop; // if polyline was shorter than the clipping distance we'd get a null polyline, so