From c09d9bc9f4d646be445c09b86a694fc37df55502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 30 Jun 2023 17:56:45 +0200 Subject: [PATCH] Don't require unitSI when reading patch record component (#1470) --- src/backend/PatchRecordComponent.cpp | 36 +++++++++++++++------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/backend/PatchRecordComponent.cpp b/src/backend/PatchRecordComponent.cpp index c418eb5fed..e9aeff78ac 100644 --- a/src/backend/PatchRecordComponent.cpp +++ b/src/backend/PatchRecordComponent.cpp @@ -143,24 +143,26 @@ void PatchRecordComponent::flush( void PatchRecordComponent::read() { - Parameter aRead; - - aRead.name = "unitSI"; - IOHandler()->enqueue(IOTask(this, aRead)); - IOHandler()->flush(internal::defaultFlushParams); - if (auto val = Attribute(*aRead.resource).getOptional(); - val.has_value()) - setUnitSI(val.value()); - else - throw error::ReadError( - error::AffectedObject::Attribute, - error::Reason::UnexpectedContent, - {}, - "Unexpected Attribute datatype for 'unitSI' (expected double, " - "found " + - datatypeToString(Attribute(*aRead.resource).dtype) + ")"); - readAttributes(ReadMode::FullyReread); // this will set dirty() = false + + if (containsAttribute("unitSI")) + { + if (auto val = getAttribute("unitSI").getOptional(); + val.has_value()) + { + setUnitSI(val.value()); + } + else + { + throw error::ReadError( + error::AffectedObject::Attribute, + error::Reason::UnexpectedContent, + {}, + "Unexpected Attribute datatype for 'unitSI' (expected double, " + "found " + + datatypeToString(getAttribute("unitSI").dtype) + ")"); + } + } } bool PatchRecordComponent::dirtyRecursive() const