From 7681eb849645799dc3952b0425a7300c9b71810e Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Tue, 1 Jun 2021 11:12:55 +0200 Subject: [PATCH] PrintRegion refactoring: Fixed a crash when an object is moved from outside the print bed inside and it becomes printable. --- src/libslic3r/PrintApply.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index 88023fee1..fe90abbd7 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1068,10 +1068,13 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ bool layer_height_ranges_differ = ! layer_height_ranges_equal(model_object.layer_config_ranges, model_object_new.layer_config_ranges, model_object_new.layer_height_profile.empty()); bool model_origin_translation_differ = model_object.origin_translation != model_object_new.origin_translation; auto print_objects_range = print_object_status_db.get_range(model_object); - assert(print_objects_range.begin() != print_objects_range.end()); + // The list actually can be empty if all instances are out of the print bed. + //assert(print_objects_range.begin() != print_objects_range.end()); // All PrintObjects in print_objects_range shall point to the same prints_objects_regions - model_object_status.print_object_regions = print_objects_range.begin()->print_object->m_shared_regions; - model_object_status.print_object_regions->ref_cnt_inc(); + if (print_objects_range.begin() != print_objects_range.end()) { + model_object_status.print_object_regions = print_objects_range.begin()->print_object->m_shared_regions; + model_object_status.print_object_regions->ref_cnt_inc(); + } if (solid_or_modifier_differ || model_origin_translation_differ || layer_height_ranges_differ || ! model_object.layer_height_profile.timestamp_matches(model_object_new.layer_height_profile)) { // The very first step (the slicing step) is invalidated. One may freely remove all associated PrintObjects.