Skip to content

Commit d93d16d

Browse files
committed
Fix dirty handling
1 parent b4b4750 commit d93d16d

10 files changed

Lines changed: 19 additions & 9 deletions

File tree

include/openPMD/backend/Attributable.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ namespace internal
5959
class SeriesData;
6060
struct HomogenizeExtents;
6161
struct ConfigAttribute;
62+
class ScientificDefaults;
6263

6364
class SharedAttributableData
6465
{
@@ -247,6 +248,7 @@ class Attributable
247248
friend class Snapshots;
248249
friend struct internal::HomogenizeExtents;
249250
friend struct internal::ConfigAttribute;
251+
friend class internal::ScientificDefaults;
250252

251253
protected:
252254
// tag for internal constructor

include/openPMD/backend/scientific_defaults/ScientificDefaults.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ class ScientificDefaults
4848
void writeDefaults(OpenpmdStandard);
4949

5050
// Called at appropriate places during parsing.
51-
void readDefaults(OpenpmdStandard);
51+
void readDefaults(Attributable &, OpenpmdStandard);
5252
};
5353
} // namespace openPMD::internal

src/Iteration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void Iteration::read_impl(std::string const &groupPath)
599599
particles.setDirty(false);
600600

601601
readAttributes(ReadMode::FullyReread);
602-
internal::ScientificDefaults::readDefaults(IOHandler()->m_standard);
602+
internal::ScientificDefaults::readDefaults(*this, IOHandler()->m_standard);
603603

604604
#ifdef openPMD_USE_INVASIVE_TESTS
605605
if (containsAttribute("__openPMD_internal_fail"))

src/Mesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ void Mesh::read()
564564
std::move(homogenizeExtents).homogenize(*this);
565565

566566
readAttributes(ReadMode::FullyReread);
567-
internal::ScientificDefaults::readDefaults(IOHandler()->m_standard);
567+
internal::ScientificDefaults::readDefaults(*this, IOHandler()->m_standard);
568568
}
569569
} // namespace openPMD
570570

src/Record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ auto Record::read() -> internal::HomogenizeExtents
197197
}
198198
}
199199

200+
internal::ScientificDefaults::readDefaults(*this, IOHandler()->m_standard);
200201
readAttributes(ReadMode::FullyReread);
201-
internal::ScientificDefaults::readDefaults(IOHandler()->m_standard);
202202

203203
return res;
204204
}

src/RecordComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ void RecordComponent::flush(
532532
void RecordComponent::read()
533533
{
534534
readBase();
535-
internal::ScientificDefaults::readDefaults(IOHandler()->m_standard);
535+
internal::ScientificDefaults::readDefaults(*this, IOHandler()->m_standard);
536536
}
537537

538538
namespace

src/backend/MeshRecordComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ MeshRecordComponent::MeshRecordComponent(
4242
void MeshRecordComponent::read()
4343
{
4444
readBase();
45-
internal::ScientificDefaults::readDefaults(IOHandler()->m_standard);
45+
internal::ScientificDefaults::readDefaults(*this, IOHandler()->m_standard);
4646
}
4747

4848
void MeshRecordComponent::flush(

src/backend/PatchRecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void PatchRecord::read()
108108
}
109109

110110
readAttributes(ReadMode::FullyReread);
111-
internal::ScientificDefaults::readDefaults(IOHandler()->m_standard);
111+
internal::ScientificDefaults::readDefaults(*this, IOHandler()->m_standard);
112112

113113
setDirty(false);
114114
}

src/backend/PatchRecordComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PatchRecordComponent::PatchRecordComponent(
6969
void PatchRecordComponent::read()
7070
{
7171
readBase();
72-
internal::ScientificDefaults::readDefaults(IOHandler()->m_standard);
72+
internal::ScientificDefaults::readDefaults(*this, IOHandler()->m_standard);
7373
}
7474

7575
PatchRecordComponent::PatchRecordComponent() : RecordComponent(NoInit())

src/backend/scientific_defaults/ScientificDefaults.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ void ScientificDefaults::writeDefaults(OpenpmdStandard standard)
2020
scientificDefaults_impl(WriteOrRead::Write, standard);
2121
}
2222

23-
void ScientificDefaults::readDefaults(OpenpmdStandard standard)
23+
void ScientificDefaults::readDefaults(
24+
Attributable &self, OpenpmdStandard standard)
2425
{
26+
auto old_dirty = self.dirty();
2527
scientificDefaults_impl(WriteOrRead::Read, standard);
28+
if (!old_dirty)
29+
{
30+
// did not become dirty by reading
31+
// but setAttribute() might have been used, so set it again
32+
self.setDirty(false);
33+
}
2634
}
2735
} // namespace openPMD::internal

0 commit comments

Comments
 (0)