From fcc781195b4286ae51bc350caf8168100b5a288e Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 9 Jul 2018 12:10:57 +0200 Subject: [PATCH] Added updating of the is_external value for edited_preset after loading preset from (.ini, .gcode, .amf, .3mf etc) --- xs/src/slic3r/GUI/Preset.hpp | 4 ++++ xs/src/slic3r/GUI/PresetBundle.cpp | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 31fb69aa8..2b88a55db 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -336,6 +336,10 @@ public: // 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) const; + // update m_edited_preset.is_external value after loading preset for .ini, .gcode, .amf, .3mf + void update_edited_preset_is_external(bool is_external) { + m_edited_preset.is_external = is_external; } + protected: // Select a preset, if it exists. If it does not exist, select an invalid (-1) index. // This is a temporary state, which shall be fixed immediately by the following step. diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 0a280eee1..070dc4791 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -505,8 +505,10 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool for (size_t i_group = 0; i_group < 2; ++ i_group) { PresetCollection &presets = (i_group == 0) ? this->prints : this->printers; Preset &preset = presets.load_preset(is_external ? name_or_path : presets.path_from_name(name), name, config); - if (is_external) + if (is_external) { preset.is_external = true; + presets.update_edited_preset_is_external(true); + } else preset.save(); } @@ -518,8 +520,10 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool if (num_extruders <= 1) { Preset &preset = this->filaments.load_preset( is_external ? name_or_path : this->filaments.path_from_name(name), name, config); - if (is_external) + if (is_external) { preset.is_external = true; + this->filaments.update_edited_preset_is_external(true); + } else preset.save(); this->filament_presets.clear(); @@ -553,8 +557,10 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool Preset &preset = this->filaments.load_preset( is_external ? name_or_path : this->filaments.path_from_name(new_name), new_name, std::move(configs[i]), i == 0); - if (is_external) + if (is_external) { preset.is_external = true; + this->filaments.update_edited_preset_is_external(true); + } else preset.save(); this->filament_presets.emplace_back(new_name);