From 4c5e3da2334a1d0c474148be8881b46d6ca6d3fa Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Mon, 17 Aug 2020 05:06:26 -0400
Subject: moved nexus api stuff to GlobalSettings pass a pointer to Settings
around for things that can be called without settings, when creating the
first instance added dummy plugin list, mod list and iorganizer to initialize
plugins without an instance moved PluginContainer into the core filter, had
nothing to do with the plugins list NexusInterface is now created manually
instead of being a static singleton because it needs to know if the settings
are available
---
src/nexusinterface.cpp | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
(limited to 'src/nexusinterface.cpp')
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp
index 396cec11..1364d7e1 100644
--- a/src/nexusinterface.cpp
+++ b/src/nexusinterface.cpp
@@ -23,6 +23,7 @@ along with Mod Organizer. If not, see .
#include "nxmaccessmanager.h"
#include "selectiondialog.h"
#include "bbcode.h"
+#include "settings.h"
#include
#include "shared/util.h"
#include
@@ -235,31 +236,42 @@ APILimits NexusInterface::parseLimits(
}
-NexusInterface::NexusInterface()
+static NexusInterface* g_instance = nullptr;
+
+NexusInterface::NexusInterface(Settings* s)
: m_PluginContainer(nullptr)
{
+ MO_ASSERT(!g_instance);
+ g_instance = this;
+
m_User.limits(defaultAPILimits());
m_MOVersion = createVersionInfo();
- m_AccessManager = new NXMAccessManager(this, m_MOVersion.displayString(3));
+ m_AccessManager = new NXMAccessManager(
+ this, s, m_MOVersion.displayString(3));
+
m_DiskCache = new QNetworkDiskCache(this);
+
connect(m_AccessManager, SIGNAL(requestNXMDownload(QString)), this, SLOT(downloadRequestedNXM(QString)));
}
-NXMAccessManager *NexusInterface::getAccessManager()
+NexusInterface::~NexusInterface()
{
- return m_AccessManager;
+ cleanup();
+
+ MO_ASSERT(g_instance == this);
+ g_instance = nullptr;
}
-NexusInterface::~NexusInterface()
+NXMAccessManager *NexusInterface::getAccessManager()
{
- cleanup();
+ return m_AccessManager;
}
NexusInterface& NexusInterface::instance()
{
- static NexusInterface ni;
- return ni;
+ MO_ASSERT(g_instance);
+ return *g_instance;
}
void NexusInterface::setCacheDirectory(const QString &directory)
--
cgit v1.3.1