mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fix: only use IApplication::instance instead of Application::instance (#5540)
This commit is contained in:
parent
1ccdaea8ee
commit
832e70e314
|
@ -124,18 +124,23 @@ SeventvEventAPI *makeSeventvEventAPI(Settings &settings)
|
|||
|
||||
const QString TWITCH_PUBSUB_URL = "wss://pubsub-edge.twitch.tv";
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
IApplication *INSTANCE = nullptr;
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
static std::atomic<bool> isAppInitialized{false};
|
||||
|
||||
Application *Application::instance = nullptr;
|
||||
IApplication *IApplication::instance = nullptr;
|
||||
|
||||
IApplication::IApplication()
|
||||
{
|
||||
IApplication::instance = this;
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
IApplication::~IApplication()
|
||||
{
|
||||
INSTANCE = nullptr;
|
||||
}
|
||||
|
||||
// this class is responsible for handling the workflow of Chatterino
|
||||
|
@ -182,8 +187,6 @@ Application::Application(Settings &_settings, const Paths &paths,
|
|||
#endif
|
||||
, updates(_updates)
|
||||
{
|
||||
Application::instance = this;
|
||||
|
||||
// We can safely ignore this signal's connection since the Application will always
|
||||
// be destroyed after fonts
|
||||
std::ignore = this->fonts->fontChanged.connect([this]() {
|
||||
|
@ -193,7 +196,8 @@ Application::Application(Settings &_settings, const Paths &paths,
|
|||
|
||||
Application::~Application()
|
||||
{
|
||||
Application::instance = nullptr;
|
||||
// we do this early to ensure getApp isn't used in any dtors
|
||||
INSTANCE = nullptr;
|
||||
}
|
||||
|
||||
void Application::initialize(Settings &settings, const Paths &paths)
|
||||
|
@ -528,6 +532,13 @@ PluginController *Application::getPlugins()
|
|||
}
|
||||
#endif
|
||||
|
||||
Updates &Application::getUpdates()
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
return this->updates;
|
||||
}
|
||||
|
||||
ITwitchIrcServer *Application::getTwitch()
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
@ -1180,9 +1191,9 @@ void Application::initSeventvEventAPI()
|
|||
|
||||
IApplication *getApp()
|
||||
{
|
||||
assert(IApplication::instance != nullptr);
|
||||
assert(INSTANCE != nullptr);
|
||||
|
||||
return IApplication::instance;
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "debug/AssertInGuiThread.hpp"
|
||||
#include "singletons/NativeMessaging.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
|
@ -62,9 +61,12 @@ class IApplication
|
|||
{
|
||||
public:
|
||||
IApplication();
|
||||
virtual ~IApplication() = default;
|
||||
virtual ~IApplication();
|
||||
|
||||
static IApplication *instance;
|
||||
IApplication(const IApplication &) = delete;
|
||||
IApplication(IApplication &&) = delete;
|
||||
IApplication &operator=(const IApplication &) = delete;
|
||||
IApplication &operator=(IApplication &&) = delete;
|
||||
|
||||
virtual bool isTest() const = 0;
|
||||
|
||||
|
@ -115,8 +117,6 @@ class Application : public IApplication
|
|||
char **argv_{};
|
||||
|
||||
public:
|
||||
static Application *instance;
|
||||
|
||||
Application(Settings &_settings, const Paths &paths, const Args &_args,
|
||||
Updates &_updates);
|
||||
~Application() override;
|
||||
|
@ -210,12 +210,7 @@ public:
|
|||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
PluginController *getPlugins() override;
|
||||
#endif
|
||||
Updates &getUpdates() override
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
return this->updates;
|
||||
}
|
||||
Updates &getUpdates() override;
|
||||
|
||||
BttvEmotes *getBttvEmotes() override;
|
||||
BttvLiveUpdates *getBttvLiveUpdates() override;
|
||||
|
@ -232,7 +227,7 @@ private:
|
|||
void initSeventvEventAPI();
|
||||
void initNm(const Paths &paths);
|
||||
|
||||
NativeMessagingServer nmServer{};
|
||||
NativeMessagingServer nmServer;
|
||||
Updates &updates;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue