diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2006-05-23 17:59:40 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2006-05-23 17:59:40 (GMT) |
commit | deec486732b7c8646cc0a2614a62b85fff336fe0 (patch) | |
tree | e2c2b4e6a939ed9aabb75b684dfdd89b9f84e148 /c++/src/H5PropList.cpp | |
parent | d0f565c5c0370424ac78a127f31a60396d280b95 (diff) | |
download | hdf5-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/H5PropList.cpp')
-rw-r--r-- | c++/src/H5PropList.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index f4981c3..3457a9d 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -97,20 +97,19 @@ PropList::PropList( const hid_t plist_id ) : IdComponent(0) //-------------------------------------------------------------------------- void PropList::copy( const PropList& like_plist ) { - // If this object has a valid id, appropriately decrement reference - // counter and close the id. + // If this object is representing an hdf5 object, close it before + // copying like_plist to it try { - decRefCount(); + close(); } catch (Exception close_error) { - throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); + throw FileIException("PropList::copy", close_error.getDetailMsg()); } - // call C routine to copy the property list - id = H5Pcopy( like_plist.getId() ); - - if( id < 0 ) - throw PropListIException(inMemFunc("copy"), "H5Pcopy failed"); + // call C routine to copy the property list + id = H5Pcopy( like_plist.getId() ); + if( id < 0 ) + throw PropListIException(inMemFunc("copy"), "H5Pcopy failed"); } //-------------------------------------------------------------------------- @@ -126,8 +125,11 @@ void PropList::copy( const PropList& like_plist ) //-------------------------------------------------------------------------- PropList& PropList::operator=( const PropList& rhs ) { - copy(rhs); - return(*this); + if (this != &rhs) + { + copy(rhs); + return(*this); + } } //-------------------------------------------------------------------------- @@ -208,18 +210,16 @@ void PropList::copyProp( PropList& dest, PropList& src, const H5std_string& name //-------------------------------------------------------------------------- void PropList::close() { - if( id != H5P_NO_CLASS ) // not a constant, should call H5Pclose - { - herr_t ret_value = H5Pclose( id ); - if( ret_value < 0 ) - { - throw PropListIException(inMemFunc("close"), "H5Pclose failed"); - } - // reset the id because the property list that it represents is now closed - id = 0; - } - else - throw PropListIException(inMemFunc("close"), "Cannot close a constant"); + if (p_valid_id(id)) + { + herr_t ret_value = H5Pclose( id ); + if( ret_value < 0 ) + { + throw PropListIException(inMemFunc("close"), "H5Pclose failed"); + } + // reset the id because the property list that it represents is now closed + id = 0; + } } //-------------------------------------------------------------------------- @@ -626,9 +626,8 @@ PropList PropList::getClassParent() const //-------------------------------------------------------------------------- PropList::~PropList() { - // The property list id will be closed properly try { - decRefCount(); + close(); } catch (Exception close_error) { cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; |