Merge pull request #7154 from Elias481/fix/serializer-object-locking-7003

Lock all kind of Objects during serialization
This commit is contained in:
Michael Friedrich 2019-05-10 14:39:27 +02:00 committed by GitHub
commit 368383bedd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -129,6 +129,8 @@ static Object::Ptr SerializeObject(const Object::Ptr& input, int attributeTypes,
DictionaryData fields;
fields.reserve(type->GetFieldCount() + 1);
ObjectLock olock(input);
for (int i = 0; i < type->GetFieldCount(); i++) {
Field field = type->GetFieldInfo(i);
@ -140,7 +142,7 @@ static Object::Ptr SerializeObject(const Object::Ptr& input, int attributeTypes,
Value value = input->GetField(i);
stack.Push(field.Name, value);
fields.emplace_back(field.Name, SerializeInternal(input->GetField(i), attributeTypes, stack));
fields.emplace_back(field.Name, SerializeInternal(value, attributeTypes, stack));
stack.Pop();
}

View File

@ -221,6 +221,7 @@ void TimePeriod::Merge(const TimePeriod::Ptr& timeperiod, bool include)
void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
{
if (clearExisting) {
ObjectLock olock(this);
SetSegments(new Array());
} else {
if (begin < GetValidEnd())
@ -346,6 +347,8 @@ void TimePeriod::UpdateTimerHandler()
void TimePeriod::Dump()
{
ObjectLock olock(this);
Array::Ptr segments = GetSegments();
Log(LogDebug, "TimePeriod")