From e35124b627b6206ba457fdfc632f2d0ac7b3553d Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 29 Jan 2019 13:36:23 +0100 Subject: [PATCH] Fix of 1.42.0.alpha2 BUG ** Printer choosing bug #1588 --- src/slic3r/GUI/Preset.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index d4ee9cf5f..f0473b823 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -531,6 +531,9 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri boost::filesystem::path dir = boost::filesystem::canonical(boost::filesystem::path(dir_path) / subdir).make_preferred(); m_dir_path = dir.string(); std::string errors_cummulative; + // Store the loaded presets into a new vector, otherwise the binary search for already existing presets would be broken. + // (see the "Preset already present, not loading" message). + std::deque presets_loaded; for (auto &dir_entry : boost::filesystem::directory_iterator(dir)) if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini") && // Ignore system and hidden files, which may be created by the DropBox synchronisation process. @@ -568,12 +571,13 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri } catch (const std::runtime_error &err) { throw std::runtime_error(std::string("Failed loading the preset file: ") + preset.file + "\n\tReason: " + err.what()); } - m_presets.emplace_back(preset); + presets_loaded.emplace_back(preset); } catch (const std::runtime_error &err) { errors_cummulative += err.what(); errors_cummulative += "\n"; } } + m_presets.insert(m_presets.end(), std::make_move_iterator(presets_loaded.begin()), std::make_move_iterator(presets_loaded.end())); std::sort(m_presets.begin() + m_num_default_presets, m_presets.end()); this->select_preset(first_visible_idx()); if (! errors_cummulative.empty())