Fix issues with supertack bed type (#8468)

- 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.
- For example, if you ever run 2.3.0-beta and having current bed type
set to the last one from the drop down, then if you use 2.2 again the
app will crash during startup.
- This PR fix this by falling back to default bed type if current value
is out of range.
- This PR also fixes issue that current bed type is changed after
upgrading to 2.3 from previous version, due to adding the supertack in
the wrong place in the enum.
This commit is contained in:
SoftFever 2025-02-20 19:59:39 +08:00 committed by GitHub
commit be8bf54884
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View file

@ -804,18 +804,18 @@ void PrintConfigDef::init_fff_params()
def->mode = comSimple;
def->enum_keys_map = &s_keys_map_BedType;
// Orca: make sure the order of the values is the same as the BedType enum
def->enum_values.emplace_back("Supertack Plate");
def->enum_values.emplace_back("Cool Plate");
def->enum_values.emplace_back("Engineering Plate");
def->enum_values.emplace_back("High Temp Plate");
def->enum_values.emplace_back("Textured PEI Plate");
def->enum_values.emplace_back("Textured Cool Plate");
def->enum_labels.emplace_back(L("Cool Plate (SuperTack)"));
def->enum_values.emplace_back("Supertack Plate");
def->enum_labels.emplace_back(L("Smooth Cool Plate"));
def->enum_labels.emplace_back(L("Engineering Plate"));
def->enum_labels.emplace_back(L("Smooth High Temp Plate"));
def->enum_labels.emplace_back(L("Textured PEI Plate"));
def->enum_labels.emplace_back(L("Textured Cool Plate"));
def->enum_labels.emplace_back(L("Cool Plate (SuperTack)"));
def->set_default_value(new ConfigOptionEnum<BedType>(btPC));
// BBS

View file

@ -268,12 +268,12 @@ enum OverhangFanThreshold {
// BBS
enum BedType {
btDefault = 0,
btSuperTack,
btPC,
btEP,
btPEI,
btPTE,
btPCT,
btSuperTack,
btCount
};

View file

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