summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-03 17:04:56 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-03 17:51:24 +0300
commit4dc93e343e0fb4990320e1056bca666e8ce8c3d9 (patch)
treed2a9220f19605f450942a0a38a18512916a3e500 /src/resources/resourcemanager.cpp
parent42411c8963eec06448a5dbf565add0540d6987f1 (diff)
downloadplus-4dc93e343e0fb4990320e1056bca666e8ce8c3d9.tar.gz
plus-4dc93e343e0fb4990320e1056bca666e8ce8c3d9.tar.bz2
plus-4dc93e343e0fb4990320e1056bca666e8ce8c3d9.tar.xz
plus-4dc93e343e0fb4990320e1056bca666e8ce8c3d9.zip
fix memory problems with atlases.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index b6befb491..ba23e4ac2 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -258,7 +258,7 @@ void ResourceManager::logResource(const Resource *const res)
#endif
}
-void ResourceManager::clearDeleted()
+void ResourceManager::clearDeleted(bool full)
{
bool status(true);
logger->log("clear deleted");
@@ -280,7 +280,7 @@ void ResourceManager::clearDeleted()
++ resDelIter;
}
}
- if (!mDeletedResources.empty())
+ if (full && !mDeletedResources.empty())
{
logger->log("leaks in deleted");
std::set<Resource*>::iterator resDelIter = mDeletedResources.begin();
@@ -783,8 +783,21 @@ void ResourceManager::release(Resource *const res)
ResourceIterator resIter = mResources.find(res->mIdPath);
+ if (resIter == mResources.end())
+ {
+ logger->log("no resource in cache: " + res->mIdPath);
+ delete res;
+ return;
+ }
+ if (resIter->second != res)
+ {
+ logger->log("in cache other image: " + res->mIdPath);
+ delete res;
+ return;
+ }
+
// The resource has to exist
- assert(resIter != mResources.end() && resIter->second == res);
+// assert(resIter != mResources.end() && resIter->second == res);
timeval tv;
gettimeofday(&tv, nullptr);