summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusintegrator.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-09-10 17:40:32 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-09-22 13:13:50 (GMT)
commitef2fcad61a316e36383e8b1e437699837f0baeda (patch)
treebdc746443f7ce298d517e685c2af250728f1225a /src/dbus/qdbusintegrator.cpp
parente824d627a8702926e81d4d5605f1a372044fbc2c (diff)
downloadQt-ef2fcad61a316e36383e8b1e437699837f0baeda.zip
Qt-ef2fcad61a316e36383e8b1e437699837f0baeda.tar.gz
Qt-ef2fcad61a316e36383e8b1e437699837f0baeda.tar.bz2
Avoid adding match rules for NameAcquired and NameLost
These two signals from org.freedesktop.DBus are delivered no matter what, because they are directed signals. So we don't need to add match rules for it. QDBusConnectionPrivate::connectSignal builds a match rule and adds it, so we shouldn't use it. Task-number: QT-3881 Reviewed-By: Robin Burchell Reviewed-By: Ritt Konstantin
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r--src/dbus/qdbusintegrator.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 98d6a32..4efea75 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1671,17 +1671,25 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
q_dbus_connection_set_timeout_functions(connection, qDBusAddTimeout, qDBusRemoveTimeout,
qDBusToggleTimeout, this, 0);
q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, 0);
-
- // Initialize the match rules
-
- connectSignal(dbusServiceString(), QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(),
- this, SLOT(registerService(QString)));
- connectSignal(dbusServiceString(), QString(), QString(), QLatin1String("NameLost"), QStringList(), QString(),
- this, SLOT(unregisterService(QString)));
-
-
q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, 0);
+ // Initialize the hooks for the NameAcquired and NameLost signals
+ // we don't use connectSignal here because we don't need the rules to be sent to the bus
+ // the bus will always send us these two signals
+ SignalHook hook;
+ hook.service = dbusServiceString();
+ hook.path.clear(); // no matching
+ hook.obj = this;
+ hook.params << QMetaType::Void << QVariant::String; // both functions take a QString as parameter and return void
+
+ hook.midx = staticMetaObject.indexOfSlot("registerService(QString)");
+ Q_ASSERT(hook.midx != -1);
+ signalHooks.insert(QLatin1String("NameAcquired:" DBUS_INTERFACE_DBUS), hook);
+
+ hook.midx = staticMetaObject.indexOfSlot("unregisterService(QString)");
+ Q_ASSERT(hook.midx != -1);
+ signalHooks.insert(QLatin1String("NameLost:" DBUS_INTERFACE_DBUS), hook);
+
qDBusDebug() << this << ": connected successfully";
// schedule a dispatch: