From 8251a60044652cd9b4abf43c04edacd973903a23 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 29 Oct 2014 11:14:04 +0100 Subject: [PATCH] Make sure that OnStateLoaded is called for all objects fixes #7482 --- lib/base/dynamicobject.cpp | 16 +++++++++++++++- lib/base/dynamicobject.ti | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 0d5d0d8b6..6b933ee0a 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -315,6 +315,7 @@ void DynamicObject::RestoreObject(const String& message, int attributeTypes) Dictionary::Ptr update = persistentObject->Get("update"); Deserialize(object, update, false, attributeTypes); object->OnStateLoaded(); + object->SetStateLoaded(true); } void DynamicObject::RestoreObjects(const String& filename, int attributeTypes) @@ -341,8 +342,21 @@ void DynamicObject::RestoreObjects(const String& filename, int attributeTypes) upq.Join(); + unsigned long no_state = 0; + + BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) { + BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) { + if (!object->GetStateLoaded()) { + object->OnStateLoaded(); + object->SetStateLoaded(true); + + no_state++; + } + } + } + Log(LogInformation, "DynamicObject") - << "Restored " << restored << " objects"; + << "Restored " << restored << " objects. Loaded " << no_state << " new objects without state."; } void DynamicObject::StopObjects(void) diff --git a/lib/base/dynamicobject.ti b/lib/base/dynamicobject.ti index 9bbc354c1..f123fbaf2 100644 --- a/lib/base/dynamicobject.ti +++ b/lib/base/dynamicobject.ti @@ -62,6 +62,8 @@ abstract class DynamicObject [protected] Dictionary::Ptr extensions; [state] Value override_vars; + + [protected] bool state_loaded; }; }