diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 269a882720..9e985286b8 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3750,8 +3750,11 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame } else { // SINGLE MATERIAL / MULTI EXTRUDER / TOOLCHANGER / IDEX Opens Dialog directly - p->editing_filament = filament_idx; - combobox->switch_to_tab(); + // -1 first, like Sidebar::edit_filament(): switch_to_tab() can run select_preset(), + // whose on_presets_changed() cascade would otherwise write into this slot mid-switch. + p->editing_filament = -1; + if (combobox->switch_to_tab()) + p->editing_filament = filament_idx; } }); combobox->edit_btn = edit_btn; diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index a5c224d17d..15b23a6cd1 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -1070,16 +1070,15 @@ bool PlaterPresetComboBox::switch_to_tab() const Preset* selected_filament_preset = nullptr; if (m_type == Preset::TYPE_FILAMENT) { - const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data(); - if (!boost::algorithm::starts_with(selected_preset, Preset::suffix_modified())) + // Reload the editor only when it has a different preset open than this slot. + const std::string& slot_preset_name = wxGetApp().preset_bundle->filament_presets[m_filament_idx]; + if (slot_preset_name != wxGetApp().preset_bundle->filaments.get_selected_preset_name()) { - const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset); - if (wxGetApp().get_tab(m_type)->select_preset(preset_name)) - wxGetApp().get_tab(m_type)->get_combo_box()->set_filament_idx(m_filament_idx); - else { + if (!wxGetApp().get_tab(m_type)->select_preset(slot_preset_name)) return false; - } } + // Bind the editor to this slot even when its preset is already open. + wxGetApp().get_tab(m_type)->get_combo_box()->set_filament_idx(m_filament_idx); } /* diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 1670970094..296074b14f 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -1050,9 +1050,11 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_ // "Transfer" / "Keep" button if (ActionButtons::TRANSFER & m_buttons) { const PresetCollection* switched_presets = type == Preset::TYPE_INVALID ? nullptr : wxGetApp().get_tab(type)->get_presets(); - if (dependent_presets && switched_presets && (type == dependent_presets->type() ? - dependent_presets->get_edited_preset().printer_technology() == dependent_presets->find_preset(new_selected_preset)->printer_technology() : - switched_presets->get_edited_preset().printer_technology() == switched_presets->find_preset(new_selected_preset)->printer_technology())) + const PresetCollection* technology_source = (dependent_presets && type == dependent_presets->type()) ? dependent_presets : switched_presets; + // find_preset() can return nullptr (e.g. an unresolved alias); guard against a null deref. + const Preset* target_preset = technology_source ? technology_source->find_preset(new_selected_preset) : nullptr; + if (dependent_presets && switched_presets && technology_source && target_preset && + technology_source->get_edited_preset().printer_technology() == target_preset->printer_technology()) add_btn(&m_transfer_btn, m_move_btn_id, "menu_paste", Action::Transfer, switched_presets->get_edited_preset().name == new_selected_preset ? _L("Transfer") : _L("Transfer"), true); } if (!m_transfer_btn && (ActionButtons::KEEP & m_buttons))