From bc4cacfee9e3bc8ac711e363c27df50e77238b78 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 5 Apr 2014 22:53:44 +0200 Subject: [PATCH] Fix validation problem with relative object names. Refs #5925 --- lib/config/aexpression.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/config/aexpression.cpp b/lib/config/aexpression.cpp index f8c877781..46e814902 100644 --- a/lib/config/aexpression.cpp +++ b/lib/config/aexpression.cpp @@ -522,12 +522,23 @@ Value AExpression::OpObject(const AExpression* expr, const Dictionary::Ptr& loca ConfigItemBuilder::Ptr item = make_shared(expr->m_DebugInfo); - ConfigItem::Ptr oldItem = ConfigItem::GetObject(type, name); + String checkName = name; - if (oldItem) { - std::ostringstream msgbuf; - msgbuf << "Object '" << name << "' of type '" << type << "' re-defined: " << expr->m_DebugInfo << "; previous definition: " << oldItem->GetDebugInfo(); - BOOST_THROW_EXCEPTION(ConfigError(msgbuf.str()) << errinfo_debuginfo(expr->m_DebugInfo)); + if (!abstract) { + const DynamicObjectNameHelper *nh = dynamic_cast(Type::GetByName(type)); + + if (nh) + checkName = nh->MakeObjectName(name, Dictionary::Ptr()); + } + + if (!checkName.IsEmpty()) { + ConfigItem::Ptr oldItem = ConfigItem::GetObject(type, name); + + if (oldItem) { + std::ostringstream msgbuf; + msgbuf << "Object '" << name << "' of type '" << type << "' re-defined: " << expr->m_DebugInfo << "; previous definition: " << oldItem->GetDebugInfo(); + BOOST_THROW_EXCEPTION(ConfigError(msgbuf.str()) << errinfo_debuginfo(expr->m_DebugInfo)); + } } item->SetType(type);