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
This commit is contained in:
Vojtech Bubnik 2021-12-20 08:30:54 +01:00
parent 62d9f73d78
commit ef66087355

View File

@ -1212,6 +1212,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if ((initial_extruder_id = tool_ordering.first_extruder()) != static_cast<unsigned int>(-1)) if ((initial_extruder_id = tool_ordering.first_extruder()) != static_cast<unsigned int>(-1))
break; break;
} }
if (initial_extruder_id == static_cast<unsigned int>(-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. // 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. // Use the extruder IDs collected from Regions.
this->set_extruders(print.extruders()); 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. // If the tool ordering has been pre-calculated by Print class for wipe tower already, reuse it.
tool_ordering = print.tool_ordering(); tool_ordering = print.tool_ordering();
tool_ordering.assign_custom_gcodes(print); 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(); 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) ? initial_extruder_id = (has_wipe_tower && ! print.config().single_extruder_multi_material_priming) ?
// The priming towers will be skipped. // The priming towers will be skipped.