summaryrefslogtreecommitdiffstats
path: root/c++/src/H5DataType.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/H5DataType.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/H5DataType.cpp')
-rw-r--r--c++/src/H5DataType.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 802714e..815faca 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -101,18 +101,17 @@ DataType::DataType(const DataType& original) : H5Object(original) {}
//--------------------------------------------------------------------------
void DataType::copy( const DataType& like_type )
{
- // reset the identifier of this instance, H5Tclose will be called
- // if needed
+ // If this object is representing an hdf5 object, close it before
+ // copying like_type to it
try {
- decRefCount();
+ close();
}
catch (Exception close_error) {
- throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg());
+ throw FileIException("DataType::copy", close_error.getDetailMsg());
}
// call C routine to copy the datatype
id = H5Tcopy( like_type.getId() );
-
if( id < 0 )
throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed");
}
@@ -130,8 +129,11 @@ void DataType::copy( const DataType& like_type )
//--------------------------------------------------------------------------
DataType& DataType::operator=( const DataType& rhs )
{
- copy(rhs);
- return(*this);
+ if (this != &rhs)
+ {
+ copy(rhs);
+ return(*this);
+ }
}
//--------------------------------------------------------------------------
@@ -636,13 +638,16 @@ DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const
//--------------------------------------------------------------------------
void DataType::close()
{
- herr_t ret_value = H5Tclose(id);
- if( ret_value < 0 )
+ if (p_valid_id(id))
{
- throw DataTypeIException(inMemFunc("close"), "H5Tclose failed");
+ herr_t ret_value = H5Tclose(id);
+ if( ret_value < 0 )
+ {
+ throw DataTypeIException(inMemFunc("close"), "H5Tclose failed");
+ }
+ // reset the id because the datatype that it represents is now closed
+ id = 0;
}
- // reset the id because the datatype that it represents is now closed
- id = 0;
}
//--------------------------------------------------------------------------
@@ -655,9 +660,8 @@ void DataType::close()
//--------------------------------------------------------------------------
DataType::~DataType()
{
- // The datatype id will be closed properly
try {
- decRefCount();
+ close();
}
catch (Exception close_error) {
cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl;