From ad1fe7574f36dc54a1a0050308c52fc15e757842 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 10 Sep 2010 17:07:29 +0200 Subject: Pre-populate the watched services hash with org.freedesktop.DBus The D-Bus specification doesn't require GetNameOwner("org.freedesktop.DBus") to return anything in specific, but the reference implementation always returns "org.freedesktop.DBus". The Python D-Bus bindings even require it. So add the same assumption to QtDBus, which saves a round-trip at the application start to ask the server what its own owner is Reviewed-By: Robin Burchell Reviewed-By: Ritt Konstantin --- src/dbus/qdbusconnection_p.h | 3 +++ src/dbus/qdbusintegrator.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 81af2c7..1bd00da 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -160,6 +160,9 @@ public: struct WatchedServiceData { WatchedServiceData() : refcount(0) {} + WatchedServiceData(const QString &owner, int refcount = 0) + : owner(owner), refcount(refcount) + {} QString owner; int refcount; }; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index cf6ca28..c7b531e 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -973,6 +973,10 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) QDBusMetaTypeId::init(); rootNode.flags = 0; + + // prepopulate watchedServices: + // we know that the owner of org.freedesktop.DBus is itself + watchedServices.insert(dbusServiceString(), WatchedServiceData(dbusServiceString(), 1)); } QDBusConnectionPrivate::~QDBusConnectionPrivate() -- cgit v0.12