diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index ac3d8da7cc..a3d8e66ac3 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -256,7 +256,9 @@ std::string GCodeWriter::set_chamber_temperature(int temperature, bool wait) return gcode.str(); } -#define EXTRUDER_LIMIT(OPT) (OPT.size() <= filament()->extruder_id() ? 0 : OPT[filament()->extruder_id()]) +#define EXTRUDER_LIMIT(OPT) \ + (filament() ? ((OPT).size() <= filament()->extruder_id() ? 0 : (OPT)[filament()->extruder_id()]) : \ + ((OPT).empty() ? 0 : *std::max_element((OPT).cbegin(), (OPT).cend()))) // copied from PrusaSlicer std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned int acceleration) diff --git a/tests/fff_print/test_printgcode.cpp b/tests/fff_print/test_printgcode.cpp index f21e6c8b06..56302df200 100644 --- a/tests/fff_print/test_printgcode.cpp +++ b/tests/fff_print/test_printgcode.cpp @@ -493,10 +493,8 @@ TEST_CASE("Machine envelope emits max limit among used extruders", "[PrintGCode] THEN("M205 contains max jerk values") { REQUIRE(gcode.find("M205 X12.00 Y13.00 Z0.60 E10.00") != std::string::npos); } - THEN("M205 J is clamped to m_max_junction_deviation (values.front())") { - // MAX_LIMIT returns 0.05, but set_junction_deviation clamps to - // m_max_junction_deviation which is set from values.front() (0.02). - REQUIRE(gcode.find("M205 J0.020") != std::string::npos); + THEN("M205 contains max m_max_junction_deviation ") { + REQUIRE(gcode.find("M205 J0.050") != std::string::npos); } } }