Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2020-03-11 20:12:16 +0300
committerbubnikv <bubnikv@gmail.com>2020-03-11 20:12:16 +0300
commitcd381d6b4f723528b6714002ffbba112a98116f6 (patch)
tree9bcc294da883b1d0a53371103047da2f3d52d0cb /src/slic3r/GUI
parenta4a6ef3c72bb18b0f249e27a19081412ec239362 (diff)
More robust vendor profile parsing.
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r--src/slic3r/GUI/AppConfig.hpp10
-rw-r--r--src/slic3r/GUI/ConfigWizard.cpp1
-rw-r--r--src/slic3r/GUI/Preset.cpp3
3 files changed, 13 insertions, 1 deletions
diff --git a/src/slic3r/GUI/AppConfig.hpp b/src/slic3r/GUI/AppConfig.hpp
index 58e04433b..c1c4607ec 100644
--- a/src/slic3r/GUI/AppConfig.hpp
+++ b/src/slic3r/GUI/AppConfig.hpp
@@ -5,6 +5,8 @@
#include <map>
#include <string>
+#include <boost/algorithm/string/trim_all.hpp>
+
#include "libslic3r/Config.hpp"
#include "libslic3r/Semver.hpp"
@@ -52,7 +54,13 @@ public:
std::string get(const std::string &key) const
{ std::string value; this->get("", key, value); return value; }
void set(const std::string &section, const std::string &key, const std::string &value)
- {
+ {
+#ifndef _NDEBUG
+ std::string key_trimmed = key;
+ boost::trim_all(key_trimmed);
+ assert(key_trimmed == key);
+ assert(! key_trimmed.empty());
+#endif _NDEBUG
std::string &old = m_storage[section][key];
if (old != value) {
old = value;
diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp
index e66922630..ac4357a2e 100644
--- a/src/slic3r/GUI/ConfigWizard.cpp
+++ b/src/slic3r/GUI/ConfigWizard.cpp
@@ -1926,6 +1926,7 @@ void ConfigWizard::priv::update_presets_in_config(const std::string& section, co
const PresetAliases& aliases = section == AppConfig::SECTION_FILAMENTS ? aliases_fff : aliases_sla;
auto update = [this, add](const std::string& s, const std::string& key) {
+ assert(! s.empty());
if (add)
appconfig_new.set(s, key, "1");
else
diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp
index b5d6392f9..28c959b69 100644
--- a/src/slic3r/GUI/Preset.cpp
+++ b/src/slic3r/GUI/Preset.cpp
@@ -189,6 +189,9 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
default_materials_field = section.second.get<std::string>("default_filaments", "");
if (Slic3r::unescape_strings_cstyle(default_materials_field, model.default_materials)) {
Slic3r::sort_remove_duplicates(model.default_materials);
+ if (! model.default_materials.empty() && model.default_materials.front().empty())
+ // An empty material was inserted into the list of default materials. Remove it.
+ model.default_materials.erase(model.default_materials.begin());
} else {
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: Malformed default_materials field: `%2%`") % id % default_materials_field;
}