From dd10edb9043fb98cd2ef27cf15fd91dfe709fc94 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 9 Jul 2013 00:57:28 -0500 Subject: [PATCH] ResourceManager stores Reloadables in a list, instead of vector. --- src/resources/ResourceManager.cpp | 16 ++++++++++++++-- src/resources/ResourceManager.h | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/resources/ResourceManager.cpp b/src/resources/ResourceManager.cpp index 1141a78c3..dbfa28d49 100644 --- a/src/resources/ResourceManager.cpp +++ b/src/resources/ResourceManager.cpp @@ -86,19 +86,31 @@ bool ResourceManager::fileExists(const std::string& path) const void ResourceManager::unloadAll() { - for(auto iter = mReloadables.begin(); iter != mReloadables.end(); iter++) + auto iter = mReloadables.begin(); + while(iter != mReloadables.end()) { if(!iter->expired()) + { iter->lock()->unload(*this); + iter++; + }else{ + mReloadables.erase(iter++); + } } } void ResourceManager::reloadAll() { - for(auto iter = mReloadables.begin(); iter != mReloadables.end(); iter++) + auto iter = mReloadables.begin(); + while(iter != mReloadables.end()) { if(!iter->expired()) + { iter->lock()->reload(*this); + iter++; + }else{ + mReloadables.erase(iter++); + } } } diff --git a/src/resources/ResourceManager.h b/src/resources/ResourceManager.h index b293c55e2..ed1d04998 100644 --- a/src/resources/ResourceManager.h +++ b/src/resources/ResourceManager.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include //The ResourceManager exists to... //Allow loading resources embedded into the executable like an actual file. @@ -38,5 +38,5 @@ public: private: ResourceData loadFile(const std::string& path) const; - std::vector< std::weak_ptr > mReloadables; + std::list< std::weak_ptr > mReloadables; };