small cleanup

This commit is contained in:
Patrick von Reth 2013-07-24 15:14:46 +02:00
parent de7993413d
commit 7e903ad093
3 changed files with 11 additions and 7 deletions

View File

@ -72,6 +72,11 @@ SnorePlugin *PluginContainer::load()
return m_instance; return m_instance;
} }
void PluginContainer::unload()
{
m_instance->deleteLater();
}
const QString & PluginContainer::file() const QString & PluginContainer::file()
{ {
return m_pluginFile; return m_pluginFile;

View File

@ -48,6 +48,7 @@ public:
PluginContainer(QString fileName,QString pluginName,PluginType type); PluginContainer(QString fileName,QString pluginName,PluginType type);
~PluginContainer(); ~PluginContainer();
SnorePlugin *load(); SnorePlugin *load();
void unload();
const QString &file(); const QString &file();
const QString &name(); const QString &name();
PluginContainer::PluginType type(); PluginContainer::PluginType type();

View File

@ -86,9 +86,8 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
} }
case PluginContainer::SECONDARY_BACKEND: case PluginContainer::SECONDARY_BACKEND:
{ {
SnoreSecondaryBackend *nb = qobject_cast<SnoreSecondaryBackend *> ( info->load() ); if(!info->load()->init( this )){
if(!nb->init( this )){ info->unload();
nb->deleteLater();
break; break;
} }
m_secondaryNotificationBackends.append(info->name()); m_secondaryNotificationBackends.append(info->name());
@ -96,10 +95,9 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
} }
case PluginContainer::FRONTEND: case PluginContainer::FRONTEND:
{ {
SnoreFrontend * nf = qobject_cast<SnoreFrontend*> (info->load());
qDebug() <<info->name()<<"is a Notification_Frontend"; qDebug() <<info->name()<<"is a Notification_Frontend";
if(!nf->init( this )){ if(!info->load()->init( this )){
nf->deleteLater(); info->unload();
break; break;
} }
m_Frontends.append(info->name()); m_Frontends.append(info->name());
@ -109,7 +107,7 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
{ {
qDebug() <<info->name()<<"is a SnorePlugin"; qDebug() <<info->name()<<"is a SnorePlugin";
if(!info->load()->init(this)){ if(!info->load()->init(this)){
info->load()->deleteLater(); info->unload();
break; break;
} }
m_plugins.append(info->name()); m_plugins.append(info->name());