Currently the API enables us within a function to open a file, open some group within that file and return the group.
Let's say we have
auto f() -> hdf5::node::Group;
The file will correctly be kept open through the RAII-object chain Group having a Link having a File. So far so good.
However, on destruction of that group returned from the file, I obtain the following error
Failed ~ObjectHandle:
ObjectHandle: could not close hid= 72057594037927939 type=FILE
The reason for this is that when at the end of a scope like this
group goes out of scope, its base, Node, will destroy its members in reverse order. Thus, first the Link link_ object is tried to be destroyed. This in turn tries to destroy the file. Which fails because there is still the open Group object from that file.
I would therefore propose to reverse the lines in Node
ObjectHandle handle_; //!< access handle to the object
Link link_; //!< stores the link to the object
to read
Link link_; //!< stores the link to the object
ObjectHandle handle_; //!< access handle to the object
If you find this acceptable I can make a MR for this change.
Currently the API enables us within a function to open a file, open some group within that file and return the group.
Let's say we have
The file will correctly be kept open through the RAII-object chain
Grouphaving aLinkhaving aFile. So far so good.However, on destruction of that group returned from the file, I obtain the following error
The reason for this is that when at the end of a scope like this
groupgoes out of scope, its base,Node, will destroy its members in reverse order. Thus, first theLink link_object is tried to be destroyed. This in turn tries to destroy the file. Which fails because there is still the openGroupobject from that file.I would therefore propose to reverse the lines in
Nodeto read
If you find this acceptable I can make a MR for this change.