summaryrefslogtreecommitdiffstats
path: root/c++/src/H5File.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2006-05-23 17:59:40 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2006-05-23 17:59:40 (GMT)
commitdeec486732b7c8646cc0a2614a62b85fff336fe0 (patch)
treee2c2b4e6a939ed9aabb75b684dfdd89b9f84e148 /c++/src/H5File.cpp
parentd0f565c5c0370424ac78a127f31a60396d280b95 (diff)
downloadhdf5-deec486732b7c8646cc0a2614a62b85fff336fe0.zip
hdf5-deec486732b7c8646cc0a2614a62b85fff336fe0.tar.gz
hdf5-deec486732b7c8646cc0a2614a62b85fff336fe0.tar.bz2
[svn-r12368] Purpose: Fixed bug
Description: Shanti compiler destroy unnamed objects later than others, which caused some reference counting test fail. Revised the test so that destructors are called at the same time, regardless the differences of compiler implementation. Revised some constructors, close, operator=, and destructors to make sure that all the object ids are handled properly. Platforms tested: Linux 2.4 (heping) SunOS 5.9 (shanti) HPUX 11.00 (kelgia) AIX 5.1 (copper)
Diffstat (limited to 'c++/src/H5File.cpp')
-rw-r--r--c++/src/H5File.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index 9550eea..79f2c61 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -49,7 +49,7 @@ namespace H5 {
///\brief Default constructor: creates a stub H5File object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File() : IdComponent() {}
+H5File::H5File() : IdComponent(0) {}
//--------------------------------------------------------------------------
// Function: H5File overloaded constructor
@@ -78,7 +78,7 @@ H5File::H5File() : IdComponent() {}
/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5F.html#File-Create
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent()
+H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent(0)
{
p_get_file(name, flags, create_plist, access_plist);
}
@@ -96,7 +96,7 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c
/// FileCreatPropList::DEFAULT
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent()
+H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent(0)
{
p_get_file(name.c_str(), flags, create_plist, access_plist);
}
@@ -258,7 +258,7 @@ void H5File::reOpen()
// If this object has a valid id, appropriately decrement reference
// counter and close the id.
try {
- decRefCount();
+ close();
}
catch (Exception close_error) {
throw FileIException("H5File::reOpen", close_error.getDetailMsg());
@@ -649,13 +649,16 @@ hid_t H5File::getLocId() const
//--------------------------------------------------------------------------
void H5File::close()
{
- herr_t ret_value = H5Fclose( id );
- if( ret_value < 0 )
- {
- throw FileIException("H5File::close", "H5Fclose failed");
- }
- // reset the id because the file that it represents is now closed
- id = 0;
+ if (p_valid_id(id))
+ {
+ herr_t ret_value = H5Fclose( id );
+ if( ret_value < 0 )
+ {
+ throw FileIException("H5File::close", "H5Fclose failed");
+ }
+ // reset the id because the file that it represents is now closed
+ id = 0;
+ }
}
//--------------------------------------------------------------------------
@@ -689,12 +692,11 @@ void H5File::throwException(const H5std_string func_name, const H5std_string msg
//--------------------------------------------------------------------------
H5File::~H5File()
{
- // The HDF5 file id will be closed properly
try {
- decRefCount();
+ close();
}
catch (Exception close_error) {
- cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl;
+ cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl;
}
}