Skip to content

Commit b3878ab

Browse files
committed
EAMxx: fix bug when aliasing subfields
1 parent b24e1fc commit b3878ab

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

components/eamxx/src/share/field/field_header.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ set_extra_data (const std::string& key,
3434

3535
std::shared_ptr<FieldHeader> FieldHeader::alias(const std::string& name) const {
3636
auto fh = create_header(get_identifier().alias(name));
37+
if (get_parent() != nullptr) {
38+
// If we're aliasing, we MUST keep track of the parent
39+
fh->create_parent_child_link(get_parent());
40+
}
3741
fh->m_tracking = m_tracking;
3842
fh->m_alloc_prop = m_alloc_prop;
3943
fh->m_extra_data = m_extra_data;

components/eamxx/src/share/tests/field_tests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ TEST_CASE("field", "") {
271271
auto g1_x0 = f1.subfield(1,0);
272272
auto g1_x1 = f1.subfield(1,1);
273273

274+
// Check we preserve parent info
275+
auto f1_0x_p = f1_0x.get_header().get_parent();
276+
REQUIRE (f1_0x.alias("foo").get_header().get_parent()==f1_0x_p);
277+
274278
REQUIRE (f1_0x.is_aliasing(g1_0x));
275279
REQUIRE (f1_1x.is_aliasing(g1_1x));
276280
REQUIRE (f1_x0.is_aliasing(g1_x0));

0 commit comments

Comments
 (0)