diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-05 21:45:27 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-05 21:45:27 +0000 |
commit | 4a43cb1c6e5ba304d70df7066c61c52718a5f249 (patch) | |
tree | d8aca0414b771cb2b7532d6f4f9d2ed87f77d703 /src/resources | |
parent | 8415f7791ea8dc84148c65d04c288d8d12eb50bf (diff) | |
download | mana-4a43cb1c6e5ba304d70df7066c61c52718a5f249.tar.gz mana-4a43cb1c6e5ba304d70df7066c61c52718a5f249.tar.bz2 mana-4a43cb1c6e5ba304d70df7066c61c52718a5f249.tar.xz mana-4a43cb1c6e5ba304d70df7066c61c52718a5f249.zip |
Fixed some resource cleanup and memory leaks. Also changed the way dangling
references to resources are reported to be more informative.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/resource.h | 6 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 15 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/resources/resource.h b/src/resources/resource.h index ce3a62fb..fe534606 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -53,6 +53,12 @@ class Resource bool decRef(); + /** + * Return the path identifying this resource. + */ + const std::string& + getIdPath() { return mIdPath; } + protected: /** * Destructor. diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index c941e16e..4a8a010a 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -31,6 +31,7 @@ #include "soundeffect.h" #include "../log.h" +#include "../gui/button.h" ResourceManager *ResourceManager::instance = NULL; @@ -43,23 +44,23 @@ ResourceManager::~ResourceManager() { // Create our resource iterator. std::map<std::string, Resource*>::iterator iter = resources.begin(); - int danglingResources = 0; - int danglingReferences = 0; // Iterate through and release references until objects are deleted. while (!resources.empty()) { Resource *res = resources.begin()->second; - danglingResources++; + std::string id = res->getIdPath(); + + int references = 0; do { - danglingReferences++; + references++; } while (!res->decRef()); - } - logger->log("ResourceManager::~ResourceManager() cleaned up %d references " - "to %d resources", danglingReferences, danglingResources); + logger->log("ResourceManager::~ResourceManager() cleaned up %d " + "references to %s", references, id.c_str()); + } } bool |