From deefd078bbcd8b68f3c595c372d6f8ca896b0d47 Mon Sep 17 00:00:00 2001 From: Nathan Hughes Date: Wed, 13 Nov 2024 21:32:53 +0000 Subject: [PATCH] avoid log errors when type is missing but config is initialized --- config_utilities/include/config_utilities/virtual_config.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config_utilities/include/config_utilities/virtual_config.h b/config_utilities/include/config_utilities/virtual_config.h index 86c0153..e24e869 100644 --- a/config_utilities/include/config_utilities/virtual_config.h +++ b/config_utilities/include/config_utilities/virtual_config.h @@ -206,13 +206,14 @@ void declare_config(VirtualConfig& config) { auto data = internal::Visitor::visitVirtualConfig(config.isSet(), config.optional_, config.getType()); // If setting values create the wrapped config using the string identifier. + const bool type_optional = config.optional_ || config.config_; if (data) { std::string type; - const bool success = config.optional_ ? internal::getTypeImpl(*data, type, Settings().factory_type_param_name) - : internal::getType(*data, type); + const bool success = type_optional ? internal::getTypeImpl(*data, type, Settings().factory_type_param_name) + : internal::getType(*data, type); if (success) { config.config_ = internal::ConfigFactory::create(type); - } else if (!config.optional_) { + } else if (!type_optional) { std::stringstream ss; ss << "Could not get type for '" << internal::ModuleInfo::fromTypes().typeInfo() << "'"; internal::Logger::logError(ss.str());