summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/resourcemanager.cpp12
-rw-r--r--src/resources/resourcemanager.h4
2 files changed, 12 insertions, 4 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index bec7914fc..50d6ccb6d 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -58,6 +58,7 @@
#include "debug.h"
+ResourceManager *resourceManager = nullptr;
ResourceManager *ResourceManager::instance = nullptr;
ResourceManager::ResourceManager() :
@@ -171,6 +172,12 @@ ResourceManager::~ResourceManager()
clearScheduled();
}
+void ResourceManager::init()
+{
+ if (!resourceManager)
+ resourceManager = new ResourceManager;
+}
+
void ResourceManager::cleanUp(Resource *const res)
{
if (!res)
@@ -949,10 +956,7 @@ void ResourceManager::decRefDelete(Resource *const res)
ResourceManager *ResourceManager::getInstance()
{
- // Create a new instance if necessary.
- if (!instance)
- instance = new ResourceManager;
- return instance;
+ return resourceManager;
}
void ResourceManager::deleteInstance()
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index 9d954cf50..9e3480380 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -255,6 +255,8 @@ class ResourceManager final
void clearCache();
+ void static init();
+
private:
/**
* Deletes the resource after logging a cleanup message.
@@ -273,4 +275,6 @@ class ResourceManager final
bool mUseLongLiveSprites;
};
+extern ResourceManager *resourceManager;
+
#endif // RESOURCES_RESOURCEMANAGER_H