From ef660873553c50a1c75feba617b16262d5e9edee Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 20 Dec 2021 08:30:54 +0100 Subject: [PATCH] Fixed crash when exporting G-code with no extrusions generated for printable object. Fixed by cancelling slicing process and emitting an exception to show a notification. Fixes carsh #7538 --- src/libslic3r/GCode.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index bd14e0a0b..def30bbde 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1212,6 +1212,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato if ((initial_extruder_id = tool_ordering.first_extruder()) != static_cast(-1)) break; } + if (initial_extruder_id == static_cast(-1)) + // No object to print was found, cancel the G-code export. + throw Slic3r::SlicingError(_(L("No extrusions were generated for objects."))); // We don't allow switching of extruders per layer by Model::custom_gcode_per_print_z in sequential mode. // Use the extruder IDs collected from Regions. this->set_extruders(print.extruders()); @@ -1220,6 +1223,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato // If the tool ordering has been pre-calculated by Print class for wipe tower already, reuse it. tool_ordering = print.tool_ordering(); tool_ordering.assign_custom_gcodes(print); + if (tool_ordering.all_extruders().empty()) + // No object to print was found, cancel the G-code export. + throw Slic3r::SlicingError(_(L("No extrusions were generated for objects."))); has_wipe_tower = print.has_wipe_tower() && tool_ordering.has_wipe_tower(); initial_extruder_id = (has_wipe_tower && ! print.config().single_extruder_multi_material_priming) ? // The priming towers will be skipped.