resource manager fix

This commit is contained in:
Turanszki Janos
2019-12-15 11:01:02 +00:00
parent 3537229633
commit deabbd64ca
2 changed files with 12 additions and 10 deletions
+11 -9
View File
@@ -42,13 +42,19 @@ namespace wiResourceManager
std::shared_ptr<wiResource> Load(const wiHashString& name)
{
locker.lock();
auto it = resources.find(name);
bool found = it != resources.end() && !it->second.expired();
locker.unlock();
std::weak_ptr<wiResource>& weak_resource = resources[name];
std::shared_ptr<wiResource> resource = weak_resource.lock();
if (found)
if (resource == nullptr)
{
return it->second.lock();
resource = std::make_shared<wiResource>();
resources[name] = resource;
locker.unlock();
}
else
{
locker.unlock();
return resource;
}
@@ -285,12 +291,8 @@ namespace wiResourceManager
if (success != nullptr)
{
locker.lock();
std::shared_ptr<wiResource> resource = std::make_shared<wiResource>();
resource->data = success;
resource->type = type;
resources.insert(make_pair(name, resource));
locker.unlock();
return resource;
}
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 36;
// minor bug fixes, alterations, refactors, updates
const int revision = 7;
const int revision = 8;
long GetVersion()