Delete existing vendors before importing newer vendors, as the existing
vendors may not be referenced by newer PrusaSlicer.ini imported.
This commit is contained in:
parent
ab245a97a4
commit
56d50d7707
4 changed files with 18 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue