You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WriteTreeToXML does not write the name attribute for SubTree nodes, breaking round-trip serialization #1262
In addTreeToXML() (src/xml_parsing.cpp), the name attribute is only written for
non-subtree nodes. For SubTreeNode, only ID (and _fullpath when metadata is enabled)
is emitted:
As a result, the instance name of a SubTree node is silently lost when a tree is exported
with WriteTreeToXML() and re-imported later.
To Reproduce
Create a tree containing a SubTree node instantiated with a custom name, e.g.:
2. Export the tree with WriteTreeToXML(tree, false, false).
3. Observe the output:
The name="my_instance" attribute is missing.
4. Re-parse the exported XML: the node's name() now falls back to the default
(registration name), so the original instance name cannot be recovered.
Expected behavior
WriteTreeToXML() should preserve the instance name of every node, including SubTree
nodes, so that export → import round-trips are lossless:
This matters for tooling that serializes a running tree and reloads it later (logging,
editing, tree-diffing), where node names are used as stable identifiers.
Proposed fix
Always set the name attribute, regardless of node type:
elem = doc.NewElement(node.registrationName().c_str());
elem->SetAttribute("name", node.name().c_str());
if(const auto* subtree = dynamic_cast<const SubTreeNode*>(&node))
{
elem->SetAttribute("ID", subtree->subtreeID().c_str());
if(add_metadata)
{
elem->SetAttribute("_fullpath", subtree->config().path.c_str());
}
}
Activity
fix: keep the name of SubTree nodes in WriteTreeToXML (#1262) (#1268)