Check missing compatible_printers error

This commit is contained in:
SoftFever 2025-01-06 20:56:07 +08:00
parent ab5aeb49d2
commit 99a0facfb3
3 changed files with 22 additions and 6 deletions

View file

@ -1174,6 +1174,7 @@ void PresetCollection::load_presets(
<< "Error in a preset file: The preset \"" << preset.file
<< "\" contains the following incorrect keys: " << incorrect_keys << ", which were removed";
}
preset.loaded = true;
//BBS: add some workaround for previous incorrect settings
if ((!preset.setting_id.empty())&&(preset.setting_id == preset.base_id))

View file

@ -4190,4 +4190,24 @@ void PresetBundle::set_default_suppressed(bool default_suppressed)
printers.set_default_suppressed(default_suppressed);
}
bool PresetBundle::has_errors() const
{
if (m_errors != 0 || printers.m_errors != 0 || filaments.m_errors != 0 || prints.m_errors != 0)
return true;
bool has_errors = false;
// Orca: check if all filament presets have compatible_printers setting
for (auto& preset : filaments) {
if (!preset.is_system)
continue;
auto* compatible_printers = dynamic_cast<const ConfigOptionStrings*>(preset.config.option("compatible_printers"));
if (compatible_printers == nullptr || compatible_printers->values.empty()) {
has_errors = true;
BOOST_LOG_TRIVIAL(error) << "Filament preset \"" << preset.file << "\" is missing compatible_printers setting";
}
}
return has_errors;
}
} // namespace Slic3r

View file

@ -274,12 +274,7 @@ public:
}
// Orca: for validation only
bool has_errors() const
{
if (m_errors != 0 || printers.m_errors != 0 || filaments.m_errors != 0 || prints.m_errors != 0)
return true;
return false;
}
bool has_errors() const;
private:
//std::pair<PresetsConfigSubstitutions, std::string> load_system_presets(ForwardCompatibilitySubstitutionRule compatibility_rule);