From 0e277ec066704ab56b6ae7ce47c7035ad65d3c67 Mon Sep 17 00:00:00 2001 From: "maosheng.wei" Date: Fri, 12 Jan 2024 15:42:27 +0800 Subject: [PATCH] FIX: Studio UI Freeze when saving user preset github: #3335 Change-Id: Idaf53f673a3e46408826c06bdde2c592395d358b --- src/libslic3r/Preset.cpp | 11 ++++------- src/libslic3r/Preset.hpp | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index e55729f5e..f3841a0a8 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -1499,7 +1499,7 @@ int PresetCollection::get_user_presets(PresetBundle *preset_bundle, std::vector< lock(); for (Preset &preset : m_presets) { if (!preset.is_user()) continue; - if (get_preset_base(preset) != &preset && preset.base_id.empty()) continue; + if (preset.base_id.empty() && preset.inherits() != "") continue; if (!preset.setting_id.empty() && preset.sync_info.empty()) continue; //if (!preset.is_bbl_vendor_preset(preset_bundle)) continue; if (preset.sync_info == "hold") continue; @@ -2286,11 +2286,8 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det // Clear the link to the parent profile. inherits.clear(); BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": save preset %1% , with detach")%new_name; - } else { - // Inherited from a user preset. Just maintain the "inherited" flag, - // meaning it will inherit from either the system preset, or the inherited user preset. - auto base = get_preset_base(curr_preset); - inherits = base ? base->name : ""; + } else if (is_base_preset(preset)) { + inherits = old_name; } preset.is_default = false; preset.is_system = false; @@ -2929,7 +2926,7 @@ std::string PresetCollection::path_from_name(const std::string &new_name, bool d std::string PresetCollection::path_for_preset(const Preset &preset) const { - return path_from_name(preset.name, get_preset_base(preset) == &preset); + return path_from_name(preset.name, is_base_preset(preset)); } const Preset& PrinterPresetCollection::default_preset_for(const DynamicPrintConfig &config) const diff --git a/src/libslic3r/Preset.hpp b/src/libslic3r/Preset.hpp index 08d020fa3..1a863264b 100644 --- a/src/libslic3r/Preset.hpp +++ b/src/libslic3r/Preset.hpp @@ -678,6 +678,7 @@ public: // Without force, the selection is only updated if the index changes. // With force, the changes are reverted if the new index is the same as the old index. bool select_preset_by_name(const std::string &name, bool force); + bool is_base_preset(const Preset &preset) const { return preset.is_system || (preset.is_user() && preset.inherits().empty()); } // Generate a file path from a profile name. Add the ".ini" suffix if it is missing. std::string path_from_name(const std::string &new_name, bool detach = false) const;