Fix crash on printer switch from stale filament/extruder indices (#14103)
Switching to a printer with fewer filaments (e.g. H2D -> X2D) threw std::out_of_range in check_filament_printable. Clear stale per-volume extruder config on count shrink and bound-check filament indices at the read sites.
This commit is contained in:
@@ -2639,8 +2639,14 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
||||
{
|
||||
auto plate_print_statistics = plate->get_slice_result()->print_statistics;
|
||||
auto plate_extruders = plate->get_extruders(true);
|
||||
auto max_extruders_colors = wxGetApp().plater()->get_extruders_colors().size();
|
||||
for (size_t extruder_id : plate_extruders) {
|
||||
extruder_id -= 1;
|
||||
// Skip stale/overflow extruder indices (e.g. from object assignments that outlived a
|
||||
// filament-count change) so downstream per-extruder lookups stay in range. Ported
|
||||
// from BambuStudio (STUDIO-15763).
|
||||
if (extruder_id >= max_extruders_colors)
|
||||
continue;
|
||||
if (plate_print_statistics.model_volumes_per_extruder.find(extruder_id) == plate_print_statistics.model_volumes_per_extruder.end())
|
||||
model_volume_of_extruders_all_plates[extruder_id] += 0;
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user