From bcab373a544b956071ba8185ce5aaea6beb97930 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Sun, 3 Feb 2019 20:17:55 +0100 Subject: [PATCH] Fixed an error when importing / exporting Config Bundles with at least one SLA print or SLA material defined. --- src/slic3r/GUI/Preset.cpp | 12 ++++++++++++ src/slic3r/GUI/Preset.hpp | 3 +++ src/slic3r/GUI/PresetBundle.cpp | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 66cc5ca4c..871cd0b73 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -1156,6 +1156,18 @@ std::string PresetCollection::name() const } } +std::string PresetCollection::section_name() const +{ + switch (this->type()) { + case Preset::TYPE_PRINT: return "print"; + case Preset::TYPE_FILAMENT: return "filament"; + case Preset::TYPE_SLA_PRINT: return "sla_print"; + case Preset::TYPE_SLA_MATERIAL: return "sla_material"; + case Preset::TYPE_PRINTER: return "printer"; + default: return "invalid"; + } +} + std::vector PresetCollection::system_preset_names() const { size_t num = 0; diff --git a/src/slic3r/GUI/Preset.hpp b/src/slic3r/GUI/Preset.hpp index eae406bef..73a921cf7 100644 --- a/src/slic3r/GUI/Preset.hpp +++ b/src/slic3r/GUI/Preset.hpp @@ -230,7 +230,10 @@ public: void reset(bool delete_files); Preset::Type type() const { return m_type; } + // Name, to be used on the screen and in error messages. Not localized. std::string name() const; + // Name, to be used as a section name in config bundle, and as a folder name for presets. + std::string section_name() const; const std::deque& operator()() const { return m_presets; } // Add default preset at the start of the collection, increment the m_default_preset counter. diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index 183c91234..5f33fd00a 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -1208,7 +1208,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla #else // Store the print/filament/printer presets at the same location as the upstream Slic3r. #endif - / presets->name() / file_name).make_preferred(); + / presets->section_name() / file_name).make_preferred(); // Load the preset into the list of presets, save it to disk. Preset &loaded = presets->load_preset(file_path.string(), preset_name, std::move(config), false); if (flags & LOAD_CFGBNDLE_SAVE) @@ -1365,7 +1365,7 @@ void PresetBundle::export_configbundle(const std::string &path, bool export_syst if (preset.is_default || preset.is_external || (preset.is_system && ! export_system_settings)) // Only export the common presets, not external files or the default preset. continue; - c << std::endl << "[" << presets->name() << ":" << preset.name << "]" << std::endl; + c << std::endl << "[" << presets->section_name() << ":" << preset.name << "]" << std::endl; for (const std::string &opt_key : preset.config.keys()) c << opt_key << " = " << preset.config.serialize(opt_key) << std::endl; }