summaryrefslogtreecommitdiffstats
path: root/c++/src/H5File.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-18 20:49:32 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-18 20:49:32 (GMT)
commitd6dc8a4dfd95ea0e6b3b6d9cfbb8ea5aad4c19d3 (patch)
treec025346989add6028cfa41893f0641171b22663d /c++/src/H5File.cpp
parent99e21e85c94327b6a525aa87a6d11547fc944f41 (diff)
downloadhdf5-d6dc8a4dfd95ea0e6b3b6d9cfbb8ea5aad4c19d3.zip
hdf5-d6dc8a4dfd95ea0e6b3b6d9cfbb8ea5aad4c19d3.tar.gz
hdf5-d6dc8a4dfd95ea0e6b3b6d9cfbb8ea5aad4c19d3.tar.bz2
[svn-r15386] Purpose: Fix bug
Description: A bug in reference counter was exposed when Ray fixed H5Awrite in the main library. ::setId() called incRefCount when it shouldn't. Made sure that id's reference counter is manually incremented properly in copy constructor and operator= only. The main library handles the rest. Platforms tested: SunOS 5.10 (linew) Linux 2.6 (kagiso) FreeBSD (duty)
Diffstat (limited to 'c++/src/H5File.cpp')
-rw-r--r--c++/src/H5File.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index 9f8e45f..7cd1936 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -754,9 +754,6 @@ void H5File::setId(const hid_t new_id)
}
// reset object's id to the given id
id = new_id;
-
- // increment the reference counter of the new id
- incRefCount();
}
//--------------------------------------------------------------------------
@@ -775,8 +772,10 @@ void H5File::close()
{
throw FileIException("H5File::close", "H5Fclose failed");
}
- // reset the id because the file that it represents is now closed
- id = 0;
+ // reset the id when the file that it represents is no longer
+ // referenced
+ if (getCounter() == 0)
+ id = 0;
}
}
@@ -813,18 +812,10 @@ void H5File::throwException(const H5std_string& func_name, const H5std_string& m
//--------------------------------------------------------------------------
H5File::~H5File()
{
- int counter = getCounter(id);
- if (counter > 1)
- {
- decRefCount(id);
- }
- else if (counter == 1)
- {
- try {
- close();
- } catch (Exception close_error) {
- cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl;
- }
+ try {
+ close();
+ } catch (Exception close_error) {
+ cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl;
}
}