Make sure all objects are set to 'active' before calling the Start() method

fixes #5224
This commit is contained in:
Gunnar Beutner 2017-05-04 10:37:34 +02:00
parent 2932651b64
commit f9f3358d09
3 changed files with 32 additions and 5 deletions

View File

@ -374,6 +374,14 @@ void ConfigObject::Start(bool runtimeCreated)
SetStartCalled(true); 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) void ConfigObject::Activate(bool runtimeCreated)
{ {
CONTEXT("Activating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'"); CONTEXT("Activating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
@ -384,8 +392,6 @@ void ConfigObject::Activate(bool runtimeCreated)
Start(runtimeCreated); Start(runtimeCreated);
ASSERT(GetStartCalled()); ASSERT(GetStartCalled());
ASSERT(!IsActive());
SetActive(true, true);
if (GetHAMode() == HARunEverywhere) if (GetHAMode() == HARunEverywhere)
SetAuthority(true); SetAuthority(true);

View File

@ -60,6 +60,7 @@ public:
void Register(void); void Register(void);
void Unregister(void); void Unregister(void);
void PreActivate(void);
void Activate(bool runtimeCreated = false); void Activate(bool runtimeCreated = false);
void Deactivate(bool runtimeRemoved = false); void Deactivate(bool runtimeRemoved = false);
void SetAuthority(bool authority); void SetAuthority(bool authority);

View File

@ -597,9 +597,6 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
} }
} }
if (!silent)
Log(LogInformation, "ConfigItem", "Triggering Start signal for config items");
for (const ConfigItem::Ptr& item : newItems) { for (const ConfigItem::Ptr& item : newItems) {
if (!item->m_Object) if (!item->m_Object)
continue; continue;
@ -609,6 +606,29 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
if (object->IsActive()) if (object->IsActive())
continue; 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 #ifdef I2_DEBUG
Log(LogDebug, "ConfigItem") Log(LogDebug, "ConfigItem")
<< "Activating object '" << object->GetName() << "' of type '" << object->GetReflectionType()->GetName() << "'"; << "Activating object '" << object->GetName() << "' of type '" << object->GetReflectionType()->GetName() << "'";