mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 21:42:43 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user