summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-11-19 12:21:04 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-11-24 20:29:53 (GMT)
commit8a820c790f2316052819148e344a3cd197877433 (patch)
treec89750f9efe2ee7681d829b334e7cfecdfda1f3f /src/dbus
parent70d0d80e5cc11f98778234ddd20ce668551e9d9d (diff)
downloadQt-8a820c790f2316052819148e344a3cd197877433.zip
Qt-8a820c790f2316052819148e344a3cd197877433.tar.gz
Qt-8a820c790f2316052819148e344a3cd197877433.tar.bz2
Fix the detection of when this process gets names on the bus.
Previously, we were relying on NameOwnerChanged to notify us of our own names. This worked because we got all NameOwnerChanged that happened on the bus. Now, we only get those we're interested in. Instead of watching for newOwner==baseService, let's just use the NameAcquired and NameLost signals, that the D-Bus server sends to us anyway. Task-number: QTBUG-5979
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/qdbusconnection_p.h5
-rw-r--r--src/dbus/qdbusintegrator.cpp18
2 files changed, 11 insertions, 12 deletions
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index 830dac3..b65e101 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -199,9 +199,6 @@ public:
QDBusMetaObject *findMetaObject(const QString &service, const QString &path,
const QString &interface, QDBusError &error);
- void registerService(const QString &serviceName);
- void unregisterService(const QString &serviceName);
-
void postEventToThread(int action, QObject *target, QEvent *event);
inline void serverConnection(const QDBusConnection &connection)
@@ -238,6 +235,8 @@ public slots:
void objectDestroyed(QObject *o);
void relaySignal(QObject *obj, const QMetaObject *, int signalId, const QVariantList &args);
void _q_serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
+ void registerService(const QString &serviceName);
+ void unregisterService(const QString &serviceName);
signals:
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 870ddd0..40febc4 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -948,9 +948,6 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
rootNode.flags = 0;
watchedServiceNames[QLatin1String(DBUS_SERVICE_DBUS)] = 1;
-
- connect(this, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
- this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
}
QDBusConnectionPrivate::~QDBusConnectionPrivate()
@@ -1180,11 +1177,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
void QDBusConnectionPrivate::_q_serviceOwnerChanged(const QString &name,
const QString &oldOwner, const QString &newOwner)
{
- if (oldOwner == baseService)
- unregisterService(name);
- if (newOwner == baseService)
- registerService(name);
-
+ Q_UNUSED(oldOwner);
QDBusWriteLocker locker(UpdateSignalHookOwnerAction, this);
QMutableHashIterator<QString, SignalHook> it(signalHooks);
it.toFront();
@@ -1655,9 +1648,16 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
baseService = QString::fromUtf8(service);
} else {
- qWarning("QDBusConnectionPrivate::SetConnection: Unable to get base service");
+ qWarning("QDBusConnectionPrivate::setConnection: Unable to get base service");
}
+ QString busService = QLatin1String(DBUS_SERVICE_DBUS);
+ connectSignal(busService, QString(), QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(),
+ this, SLOT(registerService(QString)));
+ connectSignal(busService, QString(), QString(), QString(), QLatin1String("NameLost"), QStringList(), QString(),
+ this, SLOT(unregisterService(QString)));
+
+
q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, 0);
//qDebug("base service: %s", service);