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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Bubnik <bubnikv@gmail.com>2021-12-15 15:43:30 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2021-12-15 15:43:37 +0300
commit56d50d7707a0801ee5b193843fc582ef0e6c3033 (patch)
tree116584fee827544ae245b9adaaf5f1faba07f0c5
parentab245a97a47681371b51fc328f85eab200b1b93d (diff)
Delete existing vendors before importing newer vendors, as the existing
vendors may not be referenced by newer PrusaSlicer.ini imported.
-rw-r--r--src/libslic3r/Preset.cpp2
-rw-r--r--src/libslic3r/PresetBundle.cpp22
-rw-r--r--src/libslic3r/PresetBundle.hpp2
-rw-r--r--src/slic3r/GUI/GUI_App.cpp2
4 files changed, 18 insertions, 10 deletions
diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp
index 65027a390..2397a7d19 100644
--- a/src/libslic3r/Preset.cpp
+++ b/src/libslic3r/Preset.cpp
@@ -1391,7 +1391,7 @@ const Preset* PrinterPresetCollection::find_system_preset_by_model_and_variant(c
bool PrinterPresetCollection::only_default_printers() const
{
for (const auto& printer : get_presets()) {
- if (!boost::starts_with(printer.name,"- default"))
+ if (! printer.is_default)
return false;
}
return true;
diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp
index b6e7fbd5e..81983b4aa 100644
--- a/src/libslic3r/PresetBundle.cpp
+++ b/src/libslic3r/PresetBundle.cpp
@@ -209,9 +209,16 @@ static void copy_dir(const boost::filesystem::path& from_dir, const boost::files
}
}
-void PresetBundle::copy_files(const std::string& from)
+// Import newer configuration from alternate PrusaSlicer configuration directory.
+// AppConfig from the alternate location is already loaded.
+// User profiles are being merged (old files are not being deleted),
+// while old system bundles are being deleted before newer are copied.
+void PresetBundle::import_newer_configs(const std::string& from)
{
boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir());
+ // Clean-up vendors from the target directory, as the existing vendors will not be referenced
+ // by the copied PrusaSlicer.ini
+ boost::filesystem::remove_all(data_dir / "vendor");
// list of searched paths based on current directory system in setup_directories()
// do not copy cache and snapshots
boost::filesystem::path from_data_dir = boost::filesystem::path(from);
@@ -220,7 +227,6 @@ void PresetBundle::copy_files(const std::string& from)
from_data_dir / "shapes",
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
// Store the print/filament/printer presets into a "presets" directory.
- data_dir / "presets",
data_dir / "presets" / "print",
data_dir / "presets" / "filament",
data_dir / "presets" / "sla_print",
@@ -1235,11 +1241,13 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_configbundle(
// 1) Read the complete config file into a boost::property_tree.
namespace pt = boost::property_tree;
pt::ptree tree;
- boost::nowide::ifstream ifs(path);
- try {
- pt::read_ini(ifs, tree);
- } catch (const boost::property_tree::ini_parser::ini_parser_error &err) {
- throw Slic3r::RuntimeError(format("Failed loading config bundle \"%1%\"\nError: \"%2%\" at line %3%", path, err.message(), err.line()).c_str());
+ {
+ boost::nowide::ifstream ifs(path);
+ try {
+ pt::read_ini(ifs, tree);
+ } catch (const boost::property_tree::ini_parser::ini_parser_error &err) {
+ throw Slic3r::RuntimeError(format("Failed loading config bundle \"%1%\"\nError: \"%2%\" at line %3%", path, err.message(), err.line()).c_str());
+ }
}
const VendorProfile *vendor_profile = nullptr;
diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp
index a975e37fe..2a5ce6839 100644
--- a/src/libslic3r/PresetBundle.hpp
+++ b/src/libslic3r/PresetBundle.hpp
@@ -24,7 +24,7 @@ public:
void reset(bool delete_files);
void setup_directories();
- void copy_files(const std::string& from);
+ void import_newer_configs(const std::string& from);
struct PresetPreferences {
std::string printer_model_id;// name of a preferred printer model
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 66258452a..13f76443c 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -1166,7 +1166,7 @@ bool GUI_App::on_init_inner()
preset_bundle->setup_directories();
if (! older_data_dir_path.empty())
- preset_bundle->copy_files(older_data_dir_path);
+ preset_bundle->import_newer_configs(older_data_dir_path);
// Save PrusaSlicer.ini after possibly copying the config from the alternate location and after all the configs from the alternate location were copied.
app_config->set("version", SLIC3R_VERSION);