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:
SoftFever
2026-06-08 18:57:52 +08:00
committed by GitHub
parent 0d586b28c4
commit 1e1d9cbaf8
4 changed files with 33 additions and 3 deletions

View File

@@ -764,6 +764,10 @@ void ObjectList::update_filament_values_for_items(const size_t filaments_count)
if (!object->volumes[id]->config.has("extruder") ||
size_t(object->volumes[id]->config.extruder()) > filaments_count) {
extruder = wxString::Format("%d", object->config.extruder());
// Clear the stale per-volume assignment so it falls back to the object's
// extruder; otherwise the out-of-range index survives. Ported from
// BambuStudio (STUDIO-15763).
object->volumes[id]->config.erase("extruder");
}
else {
extruder = wxString::Format("%d", object->volumes[id]->config.extruder());