From d28e964e040ea3069fd5b66dd1aac8ea4838b5ac Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sat, 14 Mar 2026 20:47:56 +0800 Subject: [PATCH] Fix crash in DiffPresetDialog::update_tree() on preset selection change (#12765) std::map::at() throws std::out_of_range when option.category or "Basic information" is not present in the tab's category_icon_map, crashing the app. Replace with a safe find()-based helper lambda that falls back to an empty string (no icon) when the key is missing. --- src/slic3r/GUI/UnsavedChangesDialog.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index ada0269330..2a74264700 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -2220,6 +2220,10 @@ void DiffPresetDialog::update_tree() m_tree->model->AddPreset(type, "\"" + from_u8(left_preset->name) + "\" vs \"" + from_u8(right_preset->name) + "\"", left_pt); const std::map& category_icon_map = wxGetApp().get_tab(type)->get_category_icon_map(); + auto get_category_icon = [&category_icon_map](const wxString& key) { + auto it = category_icon_map.find(key); + return it != category_icon_map.end() ? it->second : std::string(); + }; // process changes of extruders count if (type == Preset::TYPE_PRINTER && left_pt == ptFFF && @@ -2228,7 +2232,8 @@ void DiffPresetDialog::update_tree() wxString left_val = from_u8((boost::format("%1%") % left_config.opt("extruder_colour")->values.size()).str()); wxString right_val = from_u8((boost::format("%1%") % right_congig.opt("extruder_colour")->values.size()).str()); - m_tree->Append("extruders_count", type, "General", "Capabilities", local_label, left_val, right_val, category_icon_map.at("Basic information")); + m_tree->Append("extruders_count", type, "General", "Capabilities", local_label, left_val, right_val, + get_category_icon("Basic information")); } for (const std::string& opt_key : dirty_options) { @@ -2247,7 +2252,7 @@ void DiffPresetDialog::update_tree() continue; } m_tree->Append(opt_key, type, option.category_local, option.group_local, option.label_local, - left_val, right_val, category_icon_map.at(option.category)); + left_val, right_val, get_category_icon(option.category)); } }