From f9846eaaa50466f63d16a2abf7d997eb5610a1fa Mon Sep 17 00:00:00 2001 From: Marja Hassinen Date: Tue, 4 Jan 2011 12:03:09 +0200 Subject: lcs: Getting rid of the "cannot emit certain signals inside plugin's subscribe()". They used to deadlock the whole program since the slot handling them was trying to lock a mutex held by a function which called plugin's subscribe(). Made the mutex recursive. --- libcontextsubscriber/src/provider.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libcontextsubscriber/src/provider.cpp b/libcontextsubscriber/src/provider.cpp index 7899f4de..a38110bf 100644 --- a/libcontextsubscriber/src/provider.cpp +++ b/libcontextsubscriber/src/provider.cpp @@ -111,7 +111,7 @@ namespace ContextSubscriber { /// moves into the main thread and queues a constructPlugin call. Provider::Provider(const ContextProviderInfo& providerInfo) : plugin(0), pluginState(INITIALIZING), providerInfo(providerInfo), - pluginConstructed(false) + subscribeLock(QMutex::Recursive), pluginConstructed(false) { // Move the PropertyHandle (and all children) to main thread. moveToThread(QCoreApplication::instance()->thread()); @@ -197,16 +197,16 @@ void Provider::constructPlugin() sconnect(plugin, SIGNAL(failed(QString)), this, SLOT(onPluginFailed(QString))); - // The following signals are queued, because a plugin might emit - // subscribeFinished() right in the subscribe() call. + // The following signals (as well as valueChanged) can be emitted in + // subscribe() of the plugin. Here we utilize the fact that our mutexes are + // recursive. qRegisterMetaType("TimedValue"); sconnect(plugin, SIGNAL(subscribeFinished(QString, TimedValue)), - this, SLOT(onPluginSubscribeFinished(QString, TimedValue)), - Qt::QueuedConnection); + this, SLOT(onPluginSubscribeFinished(QString, TimedValue))); sconnect(plugin, SIGNAL(subscribeFinished(QString)), - this, SLOT(onPluginSubscribeFinished(QString)), Qt::QueuedConnection); + this, SLOT(onPluginSubscribeFinished(QString))); sconnect(plugin, SIGNAL(subscribeFailed(QString, QString)), - this, SLOT(onPluginSubscribeFailed(QString, QString)), Qt::QueuedConnection); + this, SLOT(onPluginSubscribeFailed(QString, QString))); } /// Updates \c pluginState to \c READY and requests subscription for -- cgit v1.2.3