mirror of https://github.com/Icinga/icinga2.git
parent
8b8bed6744
commit
291b000e09
|
@ -177,24 +177,32 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard)
|
||||||
if (discard)
|
if (discard)
|
||||||
m_Expression.reset();
|
m_Expression.reset();
|
||||||
|
|
||||||
String name = m_Name;
|
String item_name;
|
||||||
|
String short_name = dobj->GetShortName();
|
||||||
|
|
||||||
|
if (!short_name.IsEmpty()) {
|
||||||
|
item_name = short_name;
|
||||||
|
dobj->SetName(short_name);
|
||||||
|
} else
|
||||||
|
item_name = m_Name;
|
||||||
|
|
||||||
|
String name = item_name;
|
||||||
|
|
||||||
NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
|
NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
|
||||||
|
|
||||||
if (nc) {
|
if (nc) {
|
||||||
name = nc->MakeName(m_Name, dobj);
|
name = nc->MakeName(name, dobj);
|
||||||
|
|
||||||
if (name.IsEmpty())
|
if (name.IsEmpty())
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Could not determine name for object"));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Could not determine name for object"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name != m_Name)
|
if (name != item_name)
|
||||||
dobj->SetShortName(m_Name);
|
dobj->SetShortName(item_name);
|
||||||
|
|
||||||
dobj->SetName(name);
|
dobj->SetName(name);
|
||||||
dobj->OnConfigLoaded();
|
dobj->OnConfigLoaded();
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
m_CommittedItems.push_back(this);
|
m_CommittedItems.push_back(this);
|
||||||
|
|
Loading…
Reference in New Issue