From 520b6bbc44cf86dd0a761379e7002d850c7c0079 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 17 Jan 2014 22:45:02 +0300 Subject: fix crash on window resize. --- src/resources/resourcemanager.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/resources/resourcemanager.cpp') 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. -- cgit v1.2.3-70-g09d2