make sure snore is in the main thread

This commit is contained in:
Patrick von Reth 2015-03-05 16:25:30 +01:00
parent 49180a6495
commit 6746c248c9
4 changed files with 12 additions and 4 deletions

View File

@ -87,7 +87,7 @@ bool PluginContainer::isLoaded() const
void PluginContainer::updatePluginCache()
{
snoreDebug(SNORE_DEBUG) << "Updating plugin cache";
foreach(PluginContaienrHash list, s_pluginCache) {
for(auto list : s_pluginCache) {
foreach(PluginContainer * p, list.values()) {
delete p;
}

View File

@ -29,11 +29,15 @@
#include <iostream>
#include <QSettings>
#include <QThread>
using namespace Snore;
SnoreCore::SnoreCore()
{
if (QThread::currentThread() != qApp->thread() ) {
moveToThread(qApp->thread());
}
SnoreCorePrivate::registerMetaTypes();
d_ptr = new SnoreCorePrivate();
Q_D(SnoreCore);
@ -55,6 +59,11 @@ SnoreCore::~SnoreCore()
void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
{
if (QThread::currentThread() != thread() ) {
snoreDebug(SNORE_DEBUG) << "Delayed Plugin loading." << QThread::currentThread() << thread();
QMetaObject::invokeMethod(this, "loadPlugins", Qt::BlockingQueuedConnection, Q_ARG(Snore::SnorePlugin::PluginTypes, types));
return;
}
Q_D(SnoreCore);
setValue("PluginTypes", QVariant::fromValue(types), LOCAL_SETTING);
for (SnorePlugin::PluginTypes type : SnorePlugin::types()) {
@ -64,7 +73,6 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
if (!plugin) {
continue;
}
switch (info->type()) {
case SnorePlugin::BACKEND:
break;

View File

@ -71,7 +71,7 @@ public:
*
* @param types the type of tha plugin
*/
void loadPlugins(SnorePlugin::PluginTypes types);
Q_INVOKABLE void loadPlugins(Snore::SnorePlugin::PluginTypes types);
/**
* Broadcast a notification.

View File

@ -41,7 +41,7 @@ GrowlBackend::~GrowlBackend()
bool GrowlBackend::initialize()
{
if (Growl::init((GROWL_CALLBACK)&GrowlBackend::gntpCallback) && Growl::isRunning(GROWL_TCP)) {
if (Growl::init((GROWL_CALLBACK)&GrowlBackend::gntpCallback) && Growl::isRunning(GROWL_TCP, value("Host").toString().toUtf8().constData())) {
return SnoreBackend::initialize();
}
snoreDebug(SNORE_DEBUG) << "Growl is not running";