diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp index f155af3ba..616aee8d5 100644 --- a/lib/base/configobject.cpp +++ b/lib/base/configobject.cpp @@ -374,6 +374,14 @@ void ConfigObject::Start(bool runtimeCreated) SetStartCalled(true); } +void ConfigObject::PreActivate(void) +{ + CONTEXT("Setting 'active' to true for object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'"); + + ASSERT(!IsActive()); + SetActive(true, true); +} + void ConfigObject::Activate(bool runtimeCreated) { CONTEXT("Activating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'"); @@ -384,8 +392,6 @@ void ConfigObject::Activate(bool runtimeCreated) Start(runtimeCreated); ASSERT(GetStartCalled()); - ASSERT(!IsActive()); - SetActive(true, true); if (GetHAMode() == HARunEverywhere) SetAuthority(true); diff --git a/lib/base/configobject.hpp b/lib/base/configobject.hpp index b1f45b6f5..160594143 100644 --- a/lib/base/configobject.hpp +++ b/lib/base/configobject.hpp @@ -60,6 +60,7 @@ public: void Register(void); void Unregister(void); + void PreActivate(void); void Activate(bool runtimeCreated = false); void Deactivate(bool runtimeRemoved = false); void SetAuthority(bool authority); diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 964ec2026..91a8922f5 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -597,9 +597,6 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vectorm_Object) continue; @@ -609,6 +606,29 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vectorIsActive()) continue; +#ifdef I2_DEBUG + Log(LogDebug, "ConfigItem") + << "Setting 'active' to true for object '" << object->GetName() << "' of type '" << object->GetReflectionType()->GetName() << "'"; +#endif /* I2_DEBUG */ + upq.Enqueue(boost::bind(&ConfigObject::PreActivate, object)); + } + + upq.Join(); + + if (upq.HasExceptions()) { + upq.ReportExceptions("ConfigItem"); + return false; + } + + if (!silent) + Log(LogInformation, "ConfigItem", "Triggering Start signal for config items"); + + for (const ConfigItem::Ptr& item : newItems) { + if (!item->m_Object) + continue; + + ConfigObject::Ptr object = item->m_Object; + #ifdef I2_DEBUG Log(LogDebug, "ConfigItem") << "Activating object '" << object->GetName() << "' of type '" << object->GetReflectionType()->GetName() << "'";