summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusintegrator.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2016-05-31 11:57:53 -0300
committerThiago Macieira <thiago.macieira@intel.com>2016-08-09 02:41:22 +0000
commit6f275a4beb9a42b9d5ac99682ce9939a66239778 (patch)
treeea39e71a200d83d54cb358d744bacd2f4cd40703 /src/dbus/qdbusintegrator.cpp
parente24f89f266cee6e2473af6f66bd78f2df3a51c83 (diff)
Make sure QDBusConnection::connect() returns false if already connected
QDBusConnection::connect() behaves like QObject::connect with a connection type of Qt::UniqueConnection | Qt::QueuedConnection. So return false if it's already connected. [ChangeLog][QtDBus][QDBusConnection] Fixed a bug that would cause QDBusConnection::connect() to return true if a slot was already connected to the same D-Bus signal. QtDBus does not support multiple connections. Change-Id: I87e17314d8b24ae983b1fffd1453aef5a7c9ad0b Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r--src/dbus/qdbusintegrator.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 54418c213a..21bc3c8ac2 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -2187,20 +2187,16 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service,
// check the slot
QDBusConnectionPrivate::SignalHook hook;
QString key;
- QString name2 = name;
- if (name2.isNull())
- name2.detach();
hook.signature = signature;
if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
return false; // don't connect
Q_ASSERT(thread() != QThread::currentThread());
- emit signalNeedsConnecting(key, hook);
- return true;
+ return emit signalNeedsConnecting(key, hook);
}
-void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook &hook)
+bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook &hook)
{
QDBusWriteLocker locker(ConnectAction, this);
@@ -2216,7 +2212,7 @@ void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
entry.midx == hook.midx &&
entry.argumentMatch == hook.argumentMatch) {
// no need to compare the parameters if it's the same slot
- return; // already there
+ return false; // already there
}
}
@@ -2228,7 +2224,7 @@ void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
if (mit != matchRefCounts.end()) { // Match already present
mit.value() = mit.value() + 1;
- return;
+ return true;
}
matchRefCounts.insert(hook.matchRule, 1);
@@ -2255,6 +2251,7 @@ void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
}
}
}
+ return true;
}
bool QDBusConnectionPrivate::disconnectSignal(const QString &service,