summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-06-30 16:31:20 +0300
committerAndrei Karas <akaras@inbox.ru>2012-06-30 16:31:20 +0300
commitdffc4e4d8908f2df4eb458aa1a77c73c93213d43 (patch)
treeba5f455607cec118f198aac8bdd122fde6d19267 /src
parent177b4569cb798d8b292c66a93b42bf3224f9fdb7 (diff)
downloadManaVerse-dffc4e4d8908f2df4eb458aa1a77c73c93213d43.tar.gz
ManaVerse-dffc4e4d8908f2df4eb458aa1a77c73c93213d43.tar.bz2
ManaVerse-dffc4e4d8908f2df4eb458aa1a77c73c93213d43.tar.xz
ManaVerse-dffc4e4d8908f2df4eb458aa1a77c73c93213d43.zip
Add debug option with disabled images caching.
Diffstat (limited to 'src')
-rw-r--r--src/localconsts.h1
-rw-r--r--src/resources/resourcemanager.cpp13
2 files changed, 14 insertions, 0 deletions
diff --git a/src/localconsts.h b/src/localconsts.h
index 33cf52255..9f2454ba2 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -34,3 +34,4 @@
//#define DEBUG_CONFIG 1
//#define DEBUG_BIND_TEXTURE 1
+//#define DISABLE_RESOURCE_CACHING 1
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index ffba339c8..9b5394687 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -391,6 +391,7 @@ Resource *ResourceManager::getFromCache(const std::string &idPath)
Resource *ResourceManager::get(const std::string &idPath, generator fun,
void *data)
{
+#ifndef DISABLE_RESOURCE_CACHING
Resource *resource = getFromCache(idPath);
if (resource)
return resource;
@@ -408,6 +409,14 @@ Resource *ResourceManager::get(const std::string &idPath, generator fun,
{
logger->log("Error loaging image: " + idPath);
}
+#else
+ Resource *resource = fun(data);
+
+ if (!resource)
+ {
+ logger->log("Error loaging image: " + idPath);
+ }
+#endif
// Returns nullptr if the object could not be created.
return resource;
@@ -559,6 +568,7 @@ SpriteDef *ResourceManager::getSprite(const std::string &path, int variant)
void ResourceManager::release(Resource *res)
{
+#ifndef DISABLE_RESOURCE_CACHING
if (!res || mDestruction)
return;
@@ -577,6 +587,9 @@ void ResourceManager::release(Resource *res)
mOrphanedResources.insert(*resIter);
mResources.erase(resIter);
+#else
+ delete res;
+#endif
}
ResourceManager *ResourceManager::getInstance()