mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-30 04:11:00 +00:00
libslic3r: copy the configs a vendor keeps while resolving
A vendor keeps a copy of each config its other entries inherit, and the filament library keeps every one of them for the vendors that inherit from it. The copy was made in commit, one entry at a time on the calling thread while the workers waited, and the library alone makes 960 of them. Whether an entry's config is kept depends only on names known before any entry resolves, so resolve_vendor_preset makes the copy alongside the rest of its work and commit moves it in.
This commit is contained in:
@@ -6656,6 +6656,7 @@ PresetBundle::PresetInstall PresetBundle::resolve_vendor_preset(const CachedPres
|
||||
const VendorProfile& current_vendor_profile = *install.vendor_profile;
|
||||
const std::string& preset_name = entry.name;
|
||||
const DynamicPrintConfig* default_config = nullptr;
|
||||
const bool retain = install.is_from_lib || install.inherited.count(preset_name) != 0;
|
||||
|
||||
PresetInstall out;
|
||||
out.filament_id = entry.filament_id;
|
||||
@@ -6723,6 +6724,8 @@ PresetBundle::PresetInstall PresetBundle::resolve_vendor_preset(const CachedPres
|
||||
" contains incorrect keys: " + incorrect_keys + ", which were removed");
|
||||
if (entry.instantiation == "false" && "Template" != vendor_name) {
|
||||
out.config_only = true;
|
||||
if (retain)
|
||||
out.retained = std::move(out.config);
|
||||
return out;
|
||||
}
|
||||
if (out.config.has("alias"))
|
||||
@@ -6814,6 +6817,8 @@ PresetBundle::PresetInstall PresetBundle::resolve_vendor_preset(const CachedPres
|
||||
out.file_path = (boost::filesystem::path(data_dir()) / vendor_name / entry.sub_path).make_preferred().string();
|
||||
if (m_preserve_vendor_source_paths)
|
||||
out.file_path = (boost::filesystem::path(path) / vendor_name / entry.sub_path).make_preferred().string();
|
||||
if (retain)
|
||||
out.retained = out.config;
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -6832,11 +6837,9 @@ std::string PresetBundle::commit_vendor_preset(const CachedPreset& entry, Preset
|
||||
if (! resolved.reason.empty())
|
||||
return resolved.reason;
|
||||
|
||||
const bool retain_config = install.is_from_lib || install.inherited.count(preset_name) != 0;
|
||||
|
||||
if (resolved.config_only) {
|
||||
if (retain_config)
|
||||
install.config_maps.emplace(preset_name, std::move(resolved.config));
|
||||
if (resolved.retained)
|
||||
install.config_maps.emplace(preset_name, std::move(*resolved.retained));
|
||||
if ((presets_collection->type() == Preset::TYPE_FILAMENT) && (!resolved.filament_id.empty()))
|
||||
install.filament_id_maps.emplace(preset_name, resolved.filament_id);
|
||||
return std::string();
|
||||
@@ -6890,8 +6893,8 @@ std::string PresetBundle::commit_vendor_preset(const CachedPreset& entry, Preset
|
||||
install.substitutions->push_back({
|
||||
preset_name, presets_collection->type(), PresetConfigSubstitutions::Source::ConfigBundle,
|
||||
std::string(), std::move(substitutions) });
|
||||
if (retain_config)
|
||||
install.config_maps.emplace(preset_name, loaded.config);
|
||||
if (resolved.retained)
|
||||
install.config_maps.emplace(preset_name, std::move(*resolved.retained));
|
||||
++install.count;
|
||||
//BBS: add config related logs
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ", got preset " << loaded.name << ", filament_id " << loaded.filament_id
|
||||
|
||||
@@ -729,6 +729,9 @@ private:
|
||||
std::vector<std::string> errors;
|
||||
// What a base states for the presets that include it, when it is retained.
|
||||
std::optional<DynamicPrintConfig> included;
|
||||
// The config kept for the entries that inherit this one, or for other
|
||||
// vendors when this is the filament library.
|
||||
std::optional<DynamicPrintConfig> retained;
|
||||
// Not instantiated, so it contributes a config and no preset.
|
||||
bool config_only { false };
|
||||
// Non-empty when the entry is rejected, and says why.
|
||||
|
||||
Reference in New Issue
Block a user