Skip to content

Commit

Permalink
Fix crash when multiple objects are printed, and the first one isn't …
Browse files Browse the repository at this point in the history
…the tallest.

#4309
#4313
  • Loading branch information
supermerill committed Jun 11, 2024
1 parent 8d52314 commit 7d2f06d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3058,8 +3058,10 @@ LayerResult GCode::process_layer(
const Layer *object_layer = nullptr;
const SupportLayer *support_layer = nullptr;
const SupportLayer *raft_layer = nullptr;
const size_t layer_id = layers.front().layer()->id();
/*const*/ size_t layer_id = size_t(-1);
for (const LayerToPrint &l : layers) {
if(l.layer())
layer_id = l.layer()->id();
if (l.object_layer && ! object_layer)
object_layer = l.object_layer;
if (l.support_layer) {
Expand All @@ -3070,6 +3072,7 @@ LayerResult GCode::process_layer(
}
assert(l.layer() == nullptr || layer_id == l.layer()->id());
}
assert(layer_id < layer_count());
const Layer &layer = (object_layer != nullptr) ? *object_layer : *support_layer;
LayerResult result { {}, layer.id(), false, last_layer, false};
if (layer_tools.extruders.empty())
Expand All @@ -3082,7 +3085,7 @@ LayerResult GCode::process_layer(
m_object_sequentially_printed.insert(object_layer->object());
print.set_status(int((layer.id() * 100) / nb_layers),
std::string(L("Generating G-code layer %s / %s for object %s / %s")),
std::vector<std::string>{std::to_string(layer.id()), std::to_string(nb_layers), m_object_sequentially_printed.size(), print.num_object_instances()},
std::vector<std::string>{std::to_string(layer.id()), std::to_string(nb_layers), std::to_string(m_object_sequentially_printed.size()), std::to_string(print.num_object_instances())},
PrintBase::SlicingStatus::DEFAULT | PrintBase::SlicingStatus::SECONDARY_STATE);
} else {
print.set_status(int((layer.id() * 100) / layer_count()),
Expand Down

0 comments on commit 7d2f06d

Please sign in to comment.