-
Notifications
You must be signed in to change notification settings - Fork 22
Description
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
{
auto group = f();
}
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.