Set global SnoreCore isntance from main translation unit

Signed-off-by: Max Risuhin <risuhin.max@gmail.com>
This commit is contained in:
Max Risuhin 2018-10-15 11:44:23 +03:00
parent 0a397a3fab
commit 3bf3082ca7
No known key found for this signature in database
GPG Key ID: BF733F5ACA0B4448
5 changed files with 16 additions and 0 deletions

View File

@ -65,6 +65,7 @@ SnorePlugin *PluginContainer::load()
}
if (!m_plugin) {
m_plugin = qobject_cast<SnorePlugin *> (m_loader.instance());
m_plugin->setSnoreCoreInstance(&SnoreCore::instance());
m_plugin->m_name = name();
m_plugin->setDefaultSettings();
}

View File

@ -43,6 +43,11 @@ SnorePlugin::~SnorePlugin()
qCDebug(SNORE) << name() << this << "deleted";
}
void SnorePlugin::setSnoreCoreInstance(SnoreCore *instance)
{
SnoreCore::setInstance(instance);
}
bool SnorePlugin::isEnabled() const
{
return m_enabled;

View File

@ -29,6 +29,7 @@ namespace Snore
{
class PluginContainer;
class SnoreCore;
/**
* SnorePlugin represents the base class for the plugins.
@ -91,6 +92,8 @@ public:
SnorePlugin();
virtual ~SnorePlugin();
void setSnoreCoreInstance(SnoreCore* instance);
/**
* Sets the enabled state of the plugin to @param enabled .
*/

View File

@ -66,6 +66,12 @@ SnoreCore &SnoreCore::instance()
return *inst;
}
void SnoreCore::setInstance(SnoreCore* i)
{
qCDebug(SNORE) << "SnoreCore::setInstance Old: " << inst << " New: " << i;
inst = i;
}
SnoreCore::~SnoreCore()
{
Q_D(SnoreCore);

View File

@ -60,6 +60,7 @@ public:
* Creates a Notification Manager SnoreCore
*/
static SnoreCore &instance();
static void setInstance(SnoreCore* i);
~SnoreCore();
/**