Make SnoreCore instance static on class level

Signed-off-by: Max Risuhin <risuhin.max@gmail.com>
This commit is contained in:
Max Risuhin 2018-10-15 10:20:07 +03:00
parent 12b925a45f
commit 0a397a3fab
No known key found for this signature in database
GPG Key ID: BF733F5ACA0B4448
2 changed files with 10 additions and 4 deletions

View File

@ -32,9 +32,12 @@
#include <QGuiApplication>
#include <QSettings>
#include <QThread>
#include <QMutex>
using namespace Snore;
SnoreCore *SnoreCore::inst = nullptr;
SnoreCore::SnoreCore(QObject *parent):
QObject(parent)
{
@ -48,17 +51,19 @@ SnoreCore::SnoreCore(QObject *parent):
SnoreCore &SnoreCore::instance()
{
static SnoreCore *instance = nullptr;
if (!instance) {
qCDebug(SNORE) << "Getting SnoreCore instance: " << inst;
if (!inst) {
qCDebug(SNORE) << "Creating new SnoreCore instance: " << inst;
qRegisterMetaType<Application>();
qRegisterMetaType<LambdaHint>();
qRegisterMetaType<Notification>();
qRegisterMetaType<SnorePlugin::PluginTypes>();
qRegisterMetaTypeStreamOperators<SnorePlugin::PluginTypes>();
instance = new SnoreCore(qApp);
inst = new SnoreCore(qApp);
SnoreCorePrivate::instance()->init();
qCDebug(SNORE) << "Creating new SnoreCore instance is finished: " << inst;
}
return *instance;
return *inst;
}
SnoreCore::~SnoreCore()

View File

@ -174,6 +174,7 @@ private:
SnoreCore(QObject *parent);
SnoreCorePrivate *d_ptr;
static SnoreCore* inst;
};
}