From 08bdd4d917f905a3d1721a1692fa5d0a1a8a8da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 30 Jun 2023 10:54:43 +0200 Subject: [PATCH] Don't require unitSI when reading patch record component --- 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