Fix order for startup events.

This commit is contained in:
Gunnar Beutner 2013-08-29 19:05:06 +02:00
parent 91724814d8
commit a3eed67774
3 changed files with 11 additions and 9 deletions

View File

@ -73,12 +73,6 @@ void DynamicObject::Deserialize(const Dictionary::Ptr& update, int attributeType
ObjectLock olock(this);
InternalDeserialize(update, attributeTypes);
}
if (attributeTypes & Attribute_Config)
OnConfigLoaded();
if (attributeTypes & Attribute_State)
OnStateLoaded();
}
void DynamicObject::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const

View File

@ -82,6 +82,9 @@ public:
virtual void Start(void);
virtual void Stop(void);
virtual void OnConfigLoaded(void);
virtual void OnStateLoaded(void);
template<typename T>
static shared_ptr<T> GetObject(const String& name)
{
@ -102,9 +105,6 @@ protected:
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
virtual void OnConfigLoaded(void);
virtual void OnStateLoaded(void);
private:
String m_Name;
String m_Type;

View File

@ -275,9 +275,17 @@ void ConfigItem::ActivateItems(void)
objects.push_back(object);
}
BOOST_FOREACH(const DynamicObject::Ptr& object, objects) {
object->OnConfigLoaded();
}
/* restore the previous program state */
DynamicObject::RestoreObjects(Application::GetStatePath());
BOOST_FOREACH(const DynamicObject::Ptr& object, objects) {
object->OnStateLoaded();
}
BOOST_FOREACH(const DynamicObject::Ptr& object, objects) {
Log(LogDebug, "config", "Activating object '" + object->GetName() + "' of type '" + object->GetType()->GetName() + "'");
object->Start();