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:
authorbubnikv <bubnikv@gmail.com>2018-05-16 17:34:07 +0300
committerbubnikv <bubnikv@gmail.com>2018-05-16 17:34:07 +0300
commit687c91d6e965065af4e39589c7713df23a9cd078 (patch)
treeb4fae09cf559319297c5cd0d3530089448488bde /xs/src/slic3r/GUI/PresetBundle.cpp
parent6d98c2b1cee88c482e6a3b6b7cc0b44a951ad2c6 (diff)
Parsing of obsolete presets from Config Bundle to remove them
from user's profile when upgrading to a new configuration structure.
Diffstat (limited to 'xs/src/slic3r/GUI/PresetBundle.cpp')
-rw-r--r--xs/src/slic3r/GUI/PresetBundle.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp
index 84fa3a92f..ef48eb6d4 100644
--- a/xs/src/slic3r/GUI/PresetBundle.cpp
+++ b/xs/src/slic3r/GUI/PresetBundle.cpp
@@ -104,6 +104,9 @@ void PresetBundle::reset(bool delete_files)
this->printers .reset(delete_files);
this->filament_presets.clear();
this->filament_presets.emplace_back(this->filaments.get_selected_preset().name);
+ this->obsolete_presets.prints.clear();
+ this->obsolete_presets.filaments.clear();
+ this->obsolete_presets.printers.clear();
}
void PresetBundle::setup_directories()
@@ -224,7 +227,10 @@ std::vector<std::string> PresetBundle::merge_presets(PresetBundle &&other)
std::vector<std::string> duplicate_prints = this->prints .merge_presets(std::move(other.prints), this->vendors);
std::vector<std::string> duplicate_filaments = this->filaments.merge_presets(std::move(other.filaments), this->vendors);
std::vector<std::string> duplicate_printers = this->printers .merge_presets(std::move(other.printers), this->vendors);
- append(duplicate_prints, std::move(duplicate_filaments));
+ append(this->obsolete_presets.prints, std::move(other.obsolete_presets.prints));
+ append(this->obsolete_presets.filaments, std::move(other.obsolete_presets.filaments));
+ append(this->obsolete_presets.printers, std::move(other.obsolete_presets.printers));
+ append(duplicate_prints, std::move(duplicate_filaments));
append(duplicate_prints, std::move(duplicate_printers));
return duplicate_prints;
}
@@ -365,6 +371,7 @@ DynamicPrintConfig PresetBundle::full_config() const
} else {
// Retrieve filament presets and build a single config object for them.
// First collect the filament configurations based on the user selection of this->filament_presets.
+ // Here this->filaments.find_preset() and this->filaments.first_visible() return the edited copy of the preset if active.
std::vector<const DynamicPrintConfig*> filament_configs;
for (const std::string &filament_preset_name : this->filament_presets)
filament_configs.emplace_back(&this->filaments.find_preset(filament_preset_name, true)->config);
@@ -760,6 +767,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
flatten_configbundle_hierarchy(tree);
// 2) Parse the property_tree, extract the active preset names and the profiles, save them into local config files.
+ // Parse the obsolete preset names, to be deleted when upgrading from the old configuration structure.
std::vector<std::string> loaded_prints;
std::vector<std::string> loaded_filaments;
std::vector<std::string> loaded_printers;
@@ -799,6 +807,20 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
active_printer = kvp.second.data();
}
}
+ } else if (section.first == "obsolete_presets") {
+ // Parse the names of obsolete presets. These presets will be deleted from user's
+ // profile directory on installation of this vendor preset.
+ for (auto &kvp : section.second) {
+ std::vector<std::string> *dst = nullptr;
+ if (kvp.first == "print")
+ dst = &this->obsolete_presets.prints;
+ else if (kvp.first == "filament")
+ dst = &this->obsolete_presets.filaments;
+ else if (kvp.first == "printer")
+ dst = &this->obsolete_presets.printers;
+ if (dst)
+ unescape_strings_cstyle(kvp.second.data(), *dst);
+ }
} else if (section.first == "settings") {
// Load the settings.
for (auto &kvp : section.second) {