Fix crash when selected bed type is not supported by current version.

This could happen if you downgrade Orca to old version that does not have that bed type
This commit is contained in:
Noisyfox 2025-02-20 17:22:25 +08:00
parent ae5d7ea996
commit 088c8f5a8b

View file

@ -1298,8 +1298,10 @@ void Sidebar::update_all_preset_comboboxes()
"curr_bed_type"); "curr_bed_type");
if (!str_bed_type.empty()) { if (!str_bed_type.empty()) {
int bed_type_value = atoi(str_bed_type.c_str()); int bed_type_value = atoi(str_bed_type.c_str());
if (bed_type_value == 0) if (bed_type_value <= 0 || bed_type_value >= btCount) {
bed_type_value = 1; bed_type_value = preset_bundle.printers.get_edited_preset().get_default_bed_type(&preset_bundle);
}
m_bed_type_list->SelectAndNotify(bed_type_value - 1); m_bed_type_list->SelectAndNotify(bed_type_value - 1);
} else { } else {
BedType bed_type = preset_bundle.printers.get_edited_preset().get_default_bed_type(&preset_bundle); BedType bed_type = preset_bundle.printers.get_edited_preset().get_default_bed_type(&preset_bundle);