Name the missing parent when a dropped preset is resolved from the CLI

When load_presets() drops a preset because its parent does not exist, the
only trace is a log line. The CLI then resolves --load-settings /
--load-filaments against the loaded bundle and reports "Preset was not found
in the loaded bundle", which points at the resolver rather than at the real
cause.

Record the presets dropped for a missing parent in the collection, keyed by
file, and have resolve_preset_config() report that parent by name when the
source file is one of them.
This commit is contained in:
Hanif Koh
2026-09-09 18:28:53 +08:00
parent fb44569b8e
commit f7812bf0f1
4 changed files with 33 additions and 2 deletions
+12
View File
@@ -1624,6 +1624,7 @@ void PresetCollection::reset(bool delete_files)
unlock();
m_map_alias_to_profile_name.clear();
m_map_system_profile_renamed.clear();
m_unresolved_parents.clear();
}
void PresetCollection::add_default_preset(const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &preset_name)
@@ -1875,6 +1876,7 @@ void PresetCollection::load_presets(
if (presets_loaded.empty()) {
for (const auto &entry : deferred) {
BOOST_LOG_TRIVIAL(error) << boost::format("can not find parent %1% for config %2%!")%entry.second %entry.first.string();
m_unresolved_parents[entry.first.string()] = entry.second;
++m_errors;
}
break;
@@ -3345,6 +3347,16 @@ Preset* PresetCollection::find_preset(const std::string &name, bool first_visibl
return first_visible_if_not_found ? &this->first_visible() : nullptr;
}
std::string PresetCollection::unresolved_parent(const boost::filesystem::path &file) const
{
for (const auto &[dropped_file, parent] : m_unresolved_parents) {
boost::system::error_code ec;
if (boost::filesystem::equivalent(file, boost::filesystem::path(dropped_file), ec) && !ec)
return parent;
}
return {};
}
Preset* PresetCollection::find_preset2(const std::string& name, bool auto_match/* = true */)
{
auto preset = find_preset(name, false, true);