aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarja Hassinen <marja.hassinen@nokia.com>2011-01-04 12:03:09 +0200
committerMarja Hassinen <marja.hassinen@nokia.com>2011-01-04 12:03:09 +0200
commitf9846eaaa50466f63d16a2abf7d997eb5610a1fa (patch)
treee553f96b3ed1a5a8f008c5cc4829e39a8e95beae
parent11067c4b107df71de2d22eaa965a736df8787c1f (diff)
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.
-rw-r--r--libcontextsubscriber/src/provider.cpp14
1 files 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>("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