From 99a0facfb3a5c9b4e661e536825c08393053cb53 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Mon, 6 Jan 2025 20:56:07 +0800 Subject: [PATCH] Check missing `compatible_printers` error --- src/libslic3r/Preset.cpp | 1 + src/libslic3r/PresetBundle.cpp | 20 ++++++++++++++++++++ src/libslic3r/PresetBundle.hpp | 7 +------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index d6596b2fb9..1ed6d07ad8 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -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)) diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index ae18f5f810..039930c387 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -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(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 diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 2937937920..da952dde27 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -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 load_system_presets(ForwardCompatibilitySubstitutionRule compatibility_rule);