[Telepathy-commits] [telepathy-qt4/master] StatefulDBusProxy: Fix logic for tracking name ownership

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Jan 12 09:12:32 PST 2009


This requires the addition of a protected setBusName method.
---
 TelepathyQt4/Client/dbus-proxy.cpp |   11 ++++++-----
 TelepathyQt4/Client/dbus-proxy.h   |    3 +++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/TelepathyQt4/Client/dbus-proxy.cpp b/TelepathyQt4/Client/dbus-proxy.cpp
index 9a09854..dc5c23c 100644
--- a/TelepathyQt4/Client/dbus-proxy.cpp
+++ b/TelepathyQt4/Client/dbus-proxy.cpp
@@ -138,6 +138,9 @@ StatefulDBusProxy::StatefulDBusProxy(const QDBusConnection &dbusConnection,
 {
     QString uniqueName = busName;
 
+    connect(dbusConnection.interface(), SIGNAL(serviceOwnerChanged(QString, QString, QString)),
+            this, SLOT(onServiceOwnerChanged(QString, QString, QString)));
+
     if (!busName.startsWith(QChar(':'))) {
         // For a stateful interface, it makes no sense to follow name-owner
         // changes, so we want to bind to the unique name.
@@ -150,9 +153,7 @@ StatefulDBusProxy::StatefulDBusProxy(const QDBusConnection &dbusConnection,
         }
     }
 
-    // FIXME: Am I on crack?
-    connect(dbusConnection.interface(), SIGNAL(serviceOwnerChanged(QString, QString, QString)),
-            this, SLOT(onServiceOwnerChanged(QString, QString, QString)));
+    setBusName(uniqueName);
 }
 
 bool StatefulDBusProxy::isValid() const
@@ -205,8 +206,8 @@ void StatefulDBusProxy::emitInvalidated()
 void StatefulDBusProxy::onServiceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner)
 {
     // We only want to invalidate this object if it is not already invalidated,
-    // and it's (not any other object's) name owner changed signal is emitted.
-    if (isValid() && (name == busName())) {
+    // and its (not any other object's) name owner changed signal is emitted.
+    if (isValid() && name == busName() && newOwner == "") {
         invalidate(TELEPATHY_DBUS_ERROR_NAME_HAS_NO_OWNER,
             "Name owner lost (service crashed?)");
     }
diff --git a/TelepathyQt4/Client/dbus-proxy.h b/TelepathyQt4/Client/dbus-proxy.h
index fba4c94..788b1f9 100644
--- a/TelepathyQt4/Client/dbus-proxy.h
+++ b/TelepathyQt4/Client/dbus-proxy.h
@@ -87,6 +87,9 @@ public:
      */
     QString objectPath() const;
 
+protected:
+    void setBusName(const QString &busName);
+
 private:
     class Private;
     friend class Private;
-- 
1.5.6.5




More information about the Telepathy-commits mailing list