summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-22 01:55:26 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-22 01:55:26 +0300
commitec856b2026c7ceecab5f74942bb36661d7c6ae67 (patch)
tree43d52203d73144c184c648c8cc3badd723347079 /src
parentfb0dad2c1b014efe72f67a9da149083aee703f92 (diff)
downloadplus-ec856b2026c7ceecab5f74942bb36661d7c6ae67.tar.gz
plus-ec856b2026c7ceecab5f74942bb36661d7c6ae67.tar.bz2
plus-ec856b2026c7ceecab5f74942bb36661d7c6ae67.tar.xz
plus-ec856b2026c7ceecab5f74942bb36661d7c6ae67.zip
Add init to resource manager.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp1
-rw-r--r--src/dyetool/client.cpp1
-rw-r--r--src/resources/resourcemanager.cpp12
-rw-r--r--src/resources/resourcemanager.h4
4 files changed, 14 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp
index b19d06bb0..2e3cc7374 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -277,6 +277,7 @@ void Client::gameInit()
ConfigManager::storeSafeParameters();
#endif
+ ResourceManager::init();
const ResourceManager *const resman = ResourceManager::getInstance();
if (!resman->setWriteDir(settings.localDataDir))
{
diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp
index bdf7dc924..4722237d8 100644
--- a/src/dyetool/client.cpp
+++ b/src/dyetool/client.cpp
@@ -166,6 +166,7 @@ void Client::gameInit()
ConfigManager::storeSafeParameters();
#endif
+ ResourceManager::init();
const ResourceManager *const resman = ResourceManager::getInstance();
if (!resman->setWriteDir(settings.localDataDir))
{
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