mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 08:25:57 +08:00
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
@ -1391,7 +1391,7 @@ const Preset* PrinterPresetCollection::find_system_preset_by_model_and_variant(c
|
|||||||
bool PrinterPresetCollection::only_default_printers() const
|
bool PrinterPresetCollection::only_default_printers() const
|
||||||
{
|
{
|
||||||
for (const auto& printer : get_presets()) {
|
for (const auto& printer : get_presets()) {
|
||||||
if (!boost::starts_with(printer.name,"- default"))
|
if (! printer.is_default)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
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());
|
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()
|
// list of searched paths based on current directory system in setup_directories()
|
||||||
// do not copy cache and snapshots
|
// do not copy cache and snapshots
|
||||||
boost::filesystem::path from_data_dir = boost::filesystem::path(from);
|
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",
|
from_data_dir / "shapes",
|
||||||
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
|
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
|
||||||
// Store the print/filament/printer presets into a "presets" directory.
|
// Store the print/filament/printer presets into a "presets" directory.
|
||||||
data_dir / "presets",
|
|
||||||
data_dir / "presets" / "print",
|
data_dir / "presets" / "print",
|
||||||
data_dir / "presets" / "filament",
|
data_dir / "presets" / "filament",
|
||||||
data_dir / "presets" / "sla_print",
|
data_dir / "presets" / "sla_print",
|
||||||
@ -1235,12 +1241,14 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_configbundle(
|
|||||||
// 1) Read the complete config file into a boost::property_tree.
|
// 1) Read the complete config file into a boost::property_tree.
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
pt::ptree tree;
|
pt::ptree tree;
|
||||||
|
{
|
||||||
boost::nowide::ifstream ifs(path);
|
boost::nowide::ifstream ifs(path);
|
||||||
try {
|
try {
|
||||||
pt::read_ini(ifs, tree);
|
pt::read_ini(ifs, tree);
|
||||||
} catch (const boost::property_tree::ini_parser::ini_parser_error &err) {
|
} 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());
|
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;
|
const VendorProfile *vendor_profile = nullptr;
|
||||||
if (flags.has(LoadConfigBundleAttribute::LoadSystem) || flags.has(LoadConfigBundleAttribute::LoadVendorOnly)) {
|
if (flags.has(LoadConfigBundleAttribute::LoadSystem) || flags.has(LoadConfigBundleAttribute::LoadVendorOnly)) {
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
void reset(bool delete_files);
|
void reset(bool delete_files);
|
||||||
|
|
||||||
void setup_directories();
|
void setup_directories();
|
||||||
void copy_files(const std::string& from);
|
void import_newer_configs(const std::string& from);
|
||||||
|
|
||||||
struct PresetPreferences {
|
struct PresetPreferences {
|
||||||
std::string printer_model_id;// name of a preferred printer model
|
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();
|
preset_bundle->setup_directories();
|
||||||
|
|
||||||
if (! older_data_dir_path.empty())
|
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.
|
// 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);
|
app_config->set("version", SLIC3R_VERSION);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user