diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 2deaf1ee7..d3ff332ed 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -451,6 +451,17 @@ void ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys if (my_opt == nullptr) { // opt_key does not exist in this ConfigBase and it cannot be created, because it is not defined by this->def(). // This is only possible if other is of DynamicConfig type. + if (auto n = opt_key.find('#'); n != std::string::npos) { + auto opt_key2 = opt_key.substr(0, n); + auto my_opt2 = dynamic_cast(this->option(opt_key2, true)); + if (my_opt2) { + int index = std::atoi(opt_key.c_str() + n + 1); + auto other_opt = other.option(opt_key2); + if (other_opt) + my_opt2->set_at(other_opt, index, index); + continue; + } + } if (ignore_nonexistent) continue; throw UnknownOptionException(opt_key); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 05f6dae2c..5bf80b4a0 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1739,6 +1739,7 @@ void Tab::apply_searcher() void Tab::cache_config_diff(const std::vector& selected_options) { + m_cache_options = selected_options; m_cache_config.apply_only(m_presets->get_edited_preset().config, selected_options); } @@ -1751,8 +1752,9 @@ void Tab::apply_config_from_cache() was_applied = static_cast(this)->apply_extruder_cnt_from_cache(); if (!m_cache_config.empty()) { - m_presets->get_edited_preset().config.apply(m_cache_config); + m_presets->get_edited_preset().config.apply_only(m_cache_config, m_cache_options); m_cache_config.clear(); + m_cache_options.clear(); was_applied = true; } @@ -4737,11 +4739,15 @@ bool Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, { Preset::Type::TYPE_FILAMENT, &m_preset_bundle->filaments, ptFFF }, //{ Preset::Type::TYPE_SLA_MATERIAL, &m_preset_bundle->sla_materials,ptSLA } }; + Preset *to_be_selected = m_presets->find_preset(preset_name, false, true); + ConfigOptionStrings* cur_opt2 = dynamic_cast (m_presets->get_edited_preset().config.option("printer_extruder_variant")); + ConfigOptionStrings* to_select_opt2 = dynamic_cast (to_be_selected->config.option("printer_extruder_variant")); + no_transfer = cur_opt2->values != to_select_opt2->values; for (PresetUpdate &pu : updates) { pu.old_preset_dirty = (old_printer_technology == pu.technology) && pu.presets->current_is_dirty(); pu.new_preset_compatible = (new_printer_technology == pu.technology) && is_compatible_with_printer(pu.presets->get_edited_preset_with_vendor_profile(), new_printer_preset_with_vendor_profile); if (!canceled) - canceled = pu.old_preset_dirty && !pu.new_preset_compatible && !may_discard_current_dirty_preset(pu.presets, preset_name) && !force_select; + canceled = pu.old_preset_dirty && !pu.new_preset_compatible && !may_discard_current_dirty_preset(pu.presets, preset_name, no_transfer) && !force_select; } if (!canceled) { for (PresetUpdate &pu : updates) { diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index c95263051..0dfb83f8d 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -274,6 +274,7 @@ protected: m_highlighter; DynamicPrintConfig m_cache_config; + std::vector m_cache_options; bool m_page_switch_running = false;