From bb288f2a1b99a18d8776809a0154cf9e1026cc3a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 27 Jun 2018 15:49:02 +0200 Subject: [PATCH] Fixed a crash when complete_objects was turned on --- xs/src/libslic3r/GCode/ToolOrdering.cpp | 27 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/xs/src/libslic3r/GCode/ToolOrdering.cpp b/xs/src/libslic3r/GCode/ToolOrdering.cpp index 761e83fcc..598d3bcc6 100644 --- a/xs/src/libslic3r/GCode/ToolOrdering.cpp +++ b/xs/src/libslic3r/GCode/ToolOrdering.cpp @@ -138,15 +138,19 @@ void ToolOrdering::collect_extruders(const PrintObject &object) const PrintRegion ®ion = *object.print()->regions[region_id]; if (! layerm->perimeters.entities.empty()) { - bool something_nonoverriddable = false; - for (const auto& eec : layerm->perimeters.entities) // let's check if there are nonoverriddable entities - if (!layer_tools.wiping_extrusions.is_overriddable(dynamic_cast(*eec), *m_print_config_ptr, object, region)) { - something_nonoverriddable = true; - break; - } + bool something_nonoverriddable = true; + + if (m_print_config_ptr) { // in this case complete_objects is false (see ToolOrdering constructors) + something_nonoverriddable = false; + for (const auto& eec : layerm->perimeters.entities) // let's check if there are nonoverriddable entities + if (!layer_tools.wiping_extrusions.is_overriddable(dynamic_cast(*eec), *m_print_config_ptr, object, region)) { + something_nonoverriddable = true; + break; + } + } if (something_nonoverriddable) - layer_tools.extruders.push_back(region.config.perimeter_extruder.value); + layer_tools.extruders.push_back(region.config.perimeter_extruder.value); layer_tools.has_object = true; } @@ -164,10 +168,13 @@ void ToolOrdering::collect_extruders(const PrintObject &object) else if (role != erNone) has_infill = true; - if (!something_nonoverriddable && !layer_tools.wiping_extrusions.is_overriddable(*fill, *m_print_config_ptr, object, region)) - something_nonoverriddable = true; + if (m_print_config_ptr) { + if (!something_nonoverriddable && !layer_tools.wiping_extrusions.is_overriddable(*fill, *m_print_config_ptr, object, region)) + something_nonoverriddable = true; + } } - if (something_nonoverriddable) + + if (something_nonoverriddable || !m_print_config_ptr) { if (has_solid_infill) layer_tools.extruders.push_back(region.config.solid_infill_extruder);