mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-08 04:29:09 +08:00
Fix: Turn two Preset & PresetUpdater exceptions into error logs
This commit is contained in:
parent
28effac0f1
commit
4758b68e55
@ -18,6 +18,7 @@
|
|||||||
#include <boost/property_tree/ini_parser.hpp>
|
#include <boost/property_tree/ini_parser.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
#include <boost/locale.hpp>
|
#include <boost/locale.hpp>
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
#include <wx/choice.h>
|
#include <wx/choice.h>
|
||||||
@ -120,14 +121,15 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||||||
model.id = section.first.substr(printer_model_key.size());
|
model.id = section.first.substr(printer_model_key.size());
|
||||||
model.name = section.second.get<std::string>("name", model.id);
|
model.name = section.second.get<std::string>("name", model.id);
|
||||||
section.second.get<std::string>("variants", "");
|
section.second.get<std::string>("variants", "");
|
||||||
|
const auto variants_field = section.second.get<std::string>("variants", "");
|
||||||
std::vector<std::string> variants;
|
std::vector<std::string> variants;
|
||||||
if (Slic3r::unescape_strings_cstyle(section.second.get<std::string>("variants", ""), variants)) {
|
if (Slic3r::unescape_strings_cstyle(variants_field, variants)) {
|
||||||
for (const std::string &variant_name : variants) {
|
for (const std::string &variant_name : variants) {
|
||||||
if (model.variant(variant_name) == nullptr)
|
if (model.variant(variant_name) == nullptr)
|
||||||
model.variants.emplace_back(VendorProfile::PrinterVariant(variant_name));
|
model.variants.emplace_back(VendorProfile::PrinterVariant(variant_name));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Log error? // XXX
|
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: Malformed variants field: `%2%`") % id % variants_field;
|
||||||
}
|
}
|
||||||
if (! model.id.empty() && ! model.variants.empty())
|
if (! model.id.empty() && ! model.variants.empty())
|
||||||
res.models.push_back(std::move(model));
|
res.models.push_back(std::move(model));
|
||||||
@ -387,7 +389,9 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri
|
|||||||
// Remove the .ini suffix.
|
// Remove the .ini suffix.
|
||||||
name.erase(name.size() - 4);
|
name.erase(name.size() - 4);
|
||||||
if (this->find_preset(name, false)) {
|
if (this->find_preset(name, false)) {
|
||||||
errors_cummulative += "The user preset \"" + name + "\" cannot be loaded. A system preset of the same name has already been loaded.";
|
// This happens when there's is a preset (most likely legacy one) with the same name as a system preset
|
||||||
|
// that's already been loaded from a bundle.
|
||||||
|
BOOST_LOG_TRIVIAL(warning) << "Preset already present, not loading: " << name;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -252,7 +252,7 @@ void PresetUpdater::priv::sync_config(const std::set<VendorProfile> vendors) con
|
|||||||
// See if a there's a new version to download
|
// See if a there's a new version to download
|
||||||
const auto recommended_it = new_index.recommended();
|
const auto recommended_it = new_index.recommended();
|
||||||
if (recommended_it == new_index.end()) {
|
if (recommended_it == new_index.end()) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "No recommended version for vendor: " << vendor.name << ", invalid index?";
|
BOOST_LOG_TRIVIAL(error) << boost::format("No recommended version for vendor: %1%, invalid index?") % vendor.name;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto recommended = recommended_it->config_version;
|
const auto recommended = recommended_it->config_version;
|
||||||
@ -326,7 +326,7 @@ Updates PresetUpdater::priv::get_config_updates() const
|
|||||||
|
|
||||||
const auto recommended = idx.recommended();
|
const auto recommended = idx.recommended();
|
||||||
if (recommended == idx.end()) {
|
if (recommended == idx.end()) {
|
||||||
throw std::runtime_error((boost::format("Invalid index: `%1%`") % idx.vendor()).str());
|
BOOST_LOG_TRIVIAL(error) << boost::format("No recommended version for vendor: %1%, invalid index?") % idx.vendor();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << boost::format("Vendor: %1%, version installed: %2%, version cached: %3%")
|
BOOST_LOG_TRIVIAL(debug) << boost::format("Vendor: %1%, version installed: %2%, version cached: %3%")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user