properly unload plugins
This commit is contained in:
parent
d9efefe2c1
commit
6b30cb6562
|
@ -52,7 +52,7 @@ PluginContainer::~PluginContainer()
|
|||
|
||||
SnorePlugin *PluginContainer::load()
|
||||
{
|
||||
if ( !m_loader.load())
|
||||
if(!m_loader.isLoaded() && !m_loader.load())
|
||||
{
|
||||
snoreDebug( SNORE_WARNING ) << "Failed loading plugin: " << m_loader.errorString();
|
||||
return NULL;
|
||||
|
@ -80,6 +80,11 @@ SnorePlugin::PluginTypes PluginContainer::type()
|
|||
return m_pluginType;
|
||||
}
|
||||
|
||||
bool PluginContainer::isLoaded() const
|
||||
{
|
||||
return m_loader.isLoaded();
|
||||
}
|
||||
|
||||
SnorePlugin::PluginTypes PluginContainer::typeFromString(const QString &t)
|
||||
{
|
||||
return (SnorePlugin::PluginTypes)SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType")).keyToValue(t.toUpper().toLatin1());
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
const QString &name();
|
||||
SnorePlugin::PluginTypes type();
|
||||
|
||||
bool isLoaded() const;
|
||||
|
||||
|
||||
static SnorePlugin::PluginTypes typeFromString(const QString &t);
|
||||
static QString typeToString(const SnorePlugin::PluginTypes t);
|
||||
|
|
|
@ -23,8 +23,11 @@
|
|||
#include "plugins/plugins.h"
|
||||
#include "plugins/snorebackend.h"
|
||||
#include "plugins/snorefrontend.h"
|
||||
#include "plugins/plugincontainer.h"
|
||||
#include "notification/notification_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon):
|
||||
|
@ -32,6 +35,7 @@ SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon):
|
|||
m_defaultApp("SnoreNotify",Icon(":/root/snore.png"))
|
||||
{
|
||||
m_defaultApp.addAlert(Alert("Default",Icon(":/root/snore.png")));
|
||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
|
||||
}
|
||||
|
||||
SnoreCorePrivate::~SnoreCorePrivate()
|
||||
|
@ -85,3 +89,14 @@ void SnoreCorePrivate::slotNotificationClosed(Notification n)
|
|||
}
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::slotAboutToQuit()
|
||||
{
|
||||
foreach (PluginContainer *p, PluginContainer::pluginCache(SnorePlugin::ALL))
|
||||
{
|
||||
if(p->isLoaded())
|
||||
{
|
||||
p->load()->deinitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,6 @@ public:
|
|||
bool setBackendIfAvailible(const QString & backend);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return whether the backend can update a notification
|
||||
|
@ -68,6 +66,7 @@ signals:
|
|||
|
||||
private slots:
|
||||
void slotNotificationClosed(Snore::Notification);
|
||||
void slotAboutToQuit();
|
||||
|
||||
private:
|
||||
SnoreCore *q_ptr;
|
||||
|
|
Loading…
Reference in New Issue