Fix config validation.

Fixes #4888
This commit is contained in:
Gunnar Beutner 2013-10-16 13:37:54 +02:00
parent 53c0ea1b9e
commit 816d0e8d73
2 changed files with 18 additions and 1 deletions

View File

@ -48,7 +48,7 @@ ConfigItem::ItemMap ConfigItem::m_Items;
ConfigItem::ConfigItem(const String& type, const String& name,
bool abstract, const ExpressionList::Ptr& exprl,
const std::vector<String>& parents, const DebugInfo& debuginfo)
: m_Type(type), m_Name(name), m_Abstract(abstract),
: m_Type(type), m_Name(name), m_Abstract(abstract), m_Validated(false),
m_ExpressionList(exprl), m_ParentNames(parents), m_DebugInfo(debuginfo)
{
}
@ -235,6 +235,9 @@ ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name)
void ConfigItem::ValidateItem(void)
{
if (m_Validated)
return;
ConfigType::Ptr ctype = ConfigType::GetByName(GetType());
if (!ctype) {
@ -244,6 +247,8 @@ void ConfigItem::ValidateItem(void)
}
ctype->ValidateItem(GetSelf());
m_Validated = true;
}
bool ConfigItem::ActivateItems(bool validateOnly)
@ -258,6 +263,15 @@ bool ConfigItem::ActivateItems(bool validateOnly)
item->Link();
}
if (ConfigCompilerContext::GetInstance()->HasErrors())
return false;
Log(LogInformation, "config", "Validating config items (step 1)...");
BOOST_FOREACH(boost::tie(boost::tuples::ignore, item), m_Items) {
item->ValidateItem();
}
if (ConfigCompilerContext::GetInstance()->HasErrors())
return false;
@ -276,6 +290,8 @@ bool ConfigItem::ActivateItems(bool validateOnly)
object->OnConfigLoaded();
}
Log(LogInformation, "config", "Validating config items (step 2)...");
BOOST_FOREACH(boost::tie(boost::tuples::ignore, item), m_Items) {
item->ValidateItem();
}

View File

@ -73,6 +73,7 @@ private:
String m_Type; /**< The object type. */
String m_Name; /**< The name. */
bool m_Abstract; /**< Whether this is a template. */
bool m_Validated; /** Whether this object has been validated. */
ExpressionList::Ptr m_ExpressionList;
std::vector<String> m_ParentNames; /**< The names of parent configuration