From 9568d471af0c9774389d403c5ca0f79442bbfb89 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Sat, 1 Nov 2025 12:05:04 +0800 Subject: [PATCH] Warn if attempt to access option with wrong type --- src/libslic3r/Config.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 45bee05c2c..98cd75aad1 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -2514,7 +2515,11 @@ public: TYPE* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption *opt = this->optptr(opt_key, create); - return (opt == nullptr || opt->type() != TYPE::static_type()) ? nullptr : static_cast(opt); + if (opt != nullptr && opt->type() != TYPE::static_type()) { + BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": attempt to access option with wrong type: " << opt_key; + return nullptr; + } + return static_cast(opt); } ConfigOption* option_throw(const t_config_option_key &opt_key, bool create = false)