summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager/resourcemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/resourcemanager/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager/resourcemanager.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp
index 5ecc58732..b4e80d2c1 100644
--- a/src/resources/resourcemanager/resourcemanager.cpp
+++ b/src/resources/resourcemanager/resourcemanager.cpp
@@ -69,6 +69,7 @@ ResourceManager::~ResourceManager()
ResourceIterator iter = mResources.begin();
#ifdef DEBUG_LEAKS
+ bool status(false);
while (iter != mResources.end())
{
if (iter->second)
@@ -78,11 +79,17 @@ ResourceManager::~ResourceManager()
logger->log(std::string("ResourceLeak: ").append(
iter->second->getIdPath()).append(" (").append(
toString(iter->second->getRefCount())).append(")"));
+ status = true;
}
}
++iter;
}
+#ifdef UNITTESTS
+ if (status)
+ reportAlways("Found leaked resources.");
+#endif
+
iter = mResources.begin();
#endif
@@ -269,7 +276,11 @@ void ResourceManager::logResource(const Resource *const res)
}
else
{
- logger->log("resource(%s)", res->mIdPath.c_str());
+ std::string src = res->getSource();
+ const int count = res->getRefCount();
+ if (count > 0)
+ src.append(" ").append(toString(count));
+ logger->log("resource(%s) %s", res->mIdPath.c_str(), src.c_str());
}
#else
logger->log("resource(%s)", res->mIdPath.c_str());
@@ -631,6 +642,7 @@ void ResourceManager::deleteInstance()
logger->log1("clean orphans end");
ResourceIterator iter = resourceManager->mResources.begin();
+ bool status(false);
while (iter != resourceManager->mResources.end())
{
const Resource *const res = iter->second;
@@ -641,10 +653,15 @@ void ResourceManager::deleteInstance()
logger->log(std::string("ResourceLeak: ").append(
res->getIdPath()).append(" (").append(toString(
res->getRefCount())).append(")"));
+ status = true;
}
}
++iter;
}
+#ifdef UNITTESTS
+ if (status)
+ reportAlways("Found leaked resources.");
+#endif
}
#endif
delete2(resourceManager);