FIX: fix crash when cannot find preset

jira: STUDIO-9422
Change-Id: If81e1ac9379ccbc4b40cbda5cf8cb876ea230173
(cherry picked from commit 758d37d0807288cf63fa2b7487a65d7097b94e8e)
This commit is contained in:
zhimin.zeng 2024-12-27 14:12:47 +08:00 committed by Noisyfox
parent e0e6f77d7d
commit d19b705986
2 changed files with 5 additions and 0 deletions

View file

@ -1507,6 +1507,8 @@ void CalibrationPresetPage::update_combobox_filaments(MachineObject* obj)
}
Preset* printer_preset = get_printer_preset(obj, nozzle_value);
if (!printer_preset)
return;
auto opt_extruder_type = printer_preset->config.option<ConfigOptionEnumsGeneric>("extruder_type");
if (opt_extruder_type) {

View file

@ -1107,6 +1107,9 @@ bool Sidebar::priv::sync_extruder_list()
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
std::string target_model_id = preset_bundle->printers.get_selected_preset().get_printer_type(preset_bundle);
Preset* machine_preset = get_printer_preset(obj);
if (!machine_preset)
return false;
if (machine_print_name != target_model_id) {
MessageDialog dlg(this->plater, _L("The currently selected machine preset is inconsistent with the connected printer type.\n"
"Are you sure to continue syncing?"), _L("Sync extruder infomation"), wxICON_WARNING | wxYES | wxNO);