ResourceManager stores Reloadables in a list, instead of vector.

This commit is contained in:
Aloshi 2013-07-09 00:57:28 -05:00
parent a818801ea6
commit dd10edb904
2 changed files with 16 additions and 4 deletions

View file

@ -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++);
}
}
}

View file

@ -3,7 +3,7 @@
#include <stddef.h>
#include <memory>
#include <map>
#include <vector>
#include <list>
//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<IReloadable> > mReloadables;
std::list< std::weak_ptr<IReloadable> > mReloadables;
};