summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-07 02:28:18 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-07 02:28:18 +0100
commitdae3b06885cc10b5a728720f9424149848c797f4 (patch)
tree72fcd92d2ef7e6f4aa0bd3127fb07dbcb57777ac /api
parent07589b5114ddfc389690fdd614ee77fa411c6459 (diff)
downloadMultiMC-dae3b06885cc10b5a728720f9424149848c797f4.tar
MultiMC-dae3b06885cc10b5a728720f9424149848c797f4.tar.gz
MultiMC-dae3b06885cc10b5a728720f9424149848c797f4.tar.lz
MultiMC-dae3b06885cc10b5a728720f9424149848c797f4.tar.xz
MultiMC-dae3b06885cc10b5a728720f9424149848c797f4.zip
NOISSUE fix horrible globals crash
FIXME: remove all globals.
Diffstat (limited to 'api')
-rw-r--r--api/logic/Env.cpp15
-rw-r--r--api/logic/Env.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/api/logic/Env.cpp b/api/logic/Env.cpp
index b769c9c4..a6341ebd 100644
--- a/api/logic/Env.cpp
+++ b/api/logic/Env.cpp
@@ -22,6 +22,8 @@ public:
QString m_wonkoRootUrl;
};
+static Env * instance;
+
/*
* The *NEW* global rat nest of an object. Handle with care.
*/
@@ -38,8 +40,17 @@ Env::~Env()
Env& Env::Env::getInstance()
{
- static Env instance;
- return instance;
+ if(!instance)
+ {
+ instance = new Env();
+ }
+ return *instance;
+}
+
+void Env::dispose()
+{
+ delete instance;
+ instance = nullptr;
}
shared_qobject_ptr< HttpMetaCache > Env::metacache()
diff --git a/api/logic/Env.h b/api/logic/Env.h
index 989b4f3c..c72447ce 100644
--- a/api/logic/Env.h
+++ b/api/logic/Env.h
@@ -27,6 +27,7 @@ private:
class Private;
Env();
~Env();
+ static void dispose();
public:
static Env& getInstance();