FIX: Fix the issue where the 'get_imilar_printer_preset' method returns a null pointer

Jira: 9935

Change-Id: I4b001721780162d656b73df316387a33967e4a2c
This commit is contained in:
maosheng.wei 2025-01-17 18:01:36 +08:00 committed by lane.wei
parent 9b46d437ba
commit 2ec50f771f
1 changed files with 4 additions and 1 deletions

View File

@ -2148,7 +2148,10 @@ Preset *PresetBundle::get_similar_printer_preset(std::string printer_model, std:
if (printer_model.empty())
printer_model = printers.get_selected_preset().config.opt_string("printer_model");
auto printer_variant_old = printers.get_selected_preset().config.opt_string("printer_variant");
auto printer_names = get_printer_names_by_printer_type_and_nozzle(printer_model, printer_variant.empty() ? printer_variant_old : printer_variant, !printer_model.empty());
std::set<std::string> printer_names;
for (auto &preset : printers.m_presets) {
if (preset.config.opt_string("printer_model") == printer_model) printer_names.insert(preset.name);
}
if (printer_names.empty())
return nullptr;
auto prefer_printer = printers.get_selected_preset().name;