-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix xmdf lock #424
Fix xmdf lock #424
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks in general good, left some comments to discuss
@@ -66,6 +66,7 @@ class HdfFile | |||
Create | |||
}; | |||
typedef HdfH<H5I_FILE> Handle; | |||
typedef std::shared_ptr<Handle> SharedHandle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need new typedef
personally for me it is easier to read the code when shared_ptrs are expanded everywhere.
std::string mPath; | ||
}; | ||
|
||
typedef std::shared_ptr<HdfFile> HdfFileShared; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need new typedef
personally for me it is easier to read the code when shared_ptrs are expanded everywhere.
mdal/frmts/mdal_hdf5.hpp
Outdated
HdfGroup( std::shared_ptr<Handle> handle, HdfFile::SharedHandle file ); | ||
|
||
private: | ||
HdfFile::SharedHandle mFile; //must be the last destroyed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the commend it misleading, I would remove it. If you want to add comment, I would say do not destroy from this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the comment should be "must be declared before std::shared_ptr<Handle> d
to be sure it will be the last destroyed"
* retrieve exact behavior of FLO2D format before #424 * fix mingw build * fix narrowing conversion * ver++ * typo
For Xmdf format, when the mesh is closed (for example, removed from QGIS), the files is still locked as it is still open, and user is unable to rename or remove the file until QGIS is closed.
Indeed, the mesh is not closed properly because the file's handle is closed before the dataset's handle are closed, leading to keep the file open.
To close the mesh properly it necessary to close the file's handle once every other Hdf5 handles are closed. To achieve this, a "shared file's handle" is embeded in each HdFGroup and each HdfDataset. This member is declared before the group/dataset handle to be sure the shared handle is destroy once the group/dataset handle is effectively closed.
The destruction of the last shared handle leads to close the file.
To improve the encapsulation around HdfFile, some refactorization are also done.