From 8522a1fd4fb9974fb64264256a51162683b88dc4 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sat, 15 Feb 2014 19:42:57 +0100 Subject: [PATCH] fixed plugin loading Conflicts: src/core/plugins/plugins.cpp src/core/plugins/plugins.h --- src/core/plugins/snorebackend.cpp | 20 ++++++++++++ src/core/plugins/snorebackend.h | 2 ++ src/core/snore.cpp | 53 +++++++++++++++++-------------- 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/core/plugins/snorebackend.cpp b/src/core/plugins/snorebackend.cpp index b0d743b..29072eb 100644 --- a/src/core/plugins/snorebackend.cpp +++ b/src/core/plugins/snorebackend.cpp @@ -118,6 +118,26 @@ SnoreSecondaryBackend::~SnoreSecondaryBackend() snoreDebug( SNORE_DEBUG )<<"Deleting"<d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification))); + return true; +} + +bool SnoreSecondaryBackend::deinitialize() +{ + if(SnorePlugin::deinitialize()) + { + disconnect( snore()->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification))); + return true; + } + return false; +} + bool SnoreSecondaryBackend::supportsRichtext() { return m_supportsRichtext; diff --git a/src/core/plugins/snorebackend.h b/src/core/plugins/snorebackend.h index 231572c..faf5e3a 100644 --- a/src/core/plugins/snorebackend.h +++ b/src/core/plugins/snorebackend.h @@ -92,6 +92,8 @@ class SNORE_EXPORT SnoreSecondaryBackend : public SnorePlugin public: SnoreSecondaryBackend(const QString &name, bool supportsRhichtext); virtual ~SnoreSecondaryBackend(); + virtual bool initialize(SnoreCore *snore); + virtual bool deinitialize(); bool supportsRichtext(); diff --git a/src/core/snore.cpp b/src/core/snore.cpp index c1c8885..3de3019 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -55,32 +55,39 @@ SnoreCore::~SnoreCore() void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types ) { Q_D(SnoreCore); - foreach( PluginContainer *info, PluginContainer::pluginCache(types).values()) - { - switch(info->type()) - { - case SnorePlugin::BACKEND: - break; - case SnorePlugin::SECONDARY_BACKEND: - case SnorePlugin::FRONTEND: - case SnorePlugin::PLUGIN: - if(!info->load()->initialize( this )) - { - info->unload(); - break; - } - break; - default: - snoreDebug( SNORE_WARNING ) << "Plugin Cache corrupted\n" << info->file() << info->type(); - continue; - } - snoreDebug( SNORE_DEBUG ) << info->name() << "is a" << info->type(); - d->m_plugins[info->type()].append(info->name()); - } foreach( SnorePlugin::PluginTypes type, PluginContainer::types()) { - qSort(d->m_plugins[type]); + if(type!= SnorePlugin::ALL && types && type) + { + foreach( PluginContainer *info, PluginContainer::pluginCache(type).values()) + { + switch(info->type()) + { + case SnorePlugin::BACKEND: + break; + case SnorePlugin::SECONDARY_BACKEND: + case SnorePlugin::FRONTEND: + case SnorePlugin::PLUGIN: + if(!info->load()->initialize( this )) + { + info->unload(); + break; + } + break; + default: + snoreDebug( SNORE_WARNING ) << "Plugin Cache corrupted\n" << info->file() << info->type(); + continue; + } + snoreDebug( SNORE_DEBUG ) << info->name() << "is a" << info->type(); + d->m_plugins[info->type()].append(info->name()); + } + if(d->m_plugins.contains(type)) + { + qSort(d->m_plugins[type]); + } + } } + snoreDebug( SNORE_INFO ) << "Loaded Plugins:" << d->m_plugins; }