summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-17 22:45:02 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-17 22:45:02 +0300
commit520b6bbc44cf86dd0a761379e7002d850c7c0079 (patch)
tree0cc9243ec652d011b891d488099ab74f91e07ec6 /src/resources/resourcemanager.cpp
parent154186bc49d49f1c20c3fcf8ec79494460ed63af (diff)
downloadmanaplus-520b6bbc44cf86dd0a761379e7002d850c7c0079.tar.gz
manaplus-520b6bbc44cf86dd0a761379e7002d850c7c0079.tar.bz2
manaplus-520b6bbc44cf86dd0a761379e7002d850c7c0079.tar.xz
manaplus-520b6bbc44cf86dd0a761379e7002d850c7c0079.zip
fix crash on window resize.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 00fe37c75..fa0717622 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -887,6 +887,37 @@ void ResourceManager::moveToDeleted(Resource *const res)
}
}
+void ResourceManager::decRefDelete(Resource *const res)
+{
+ if (!res)
+ return;
+
+ bool found(false);
+ const int count = res->getRefCount();
+ if (count == 1)
+ {
+ logResource(res);
+
+ ResourceIterator resIter = mResources.find(res->mIdPath);
+ if (resIter != mResources.end() && resIter->second == res)
+ {
+ mResources.erase(resIter);
+ }
+ else
+ {
+ resIter = mOrphanedResources.find(res->mIdPath);
+ if (resIter != mOrphanedResources.end() && resIter->second == res)
+ mOrphanedResources.erase(resIter);
+ }
+
+ delete res;
+ }
+ else
+ {
+ res->decRef();
+ }
+}
+
ResourceManager *ResourceManager::getInstance()
{
// Create a new instance if necessary.