telepathy-qt: Adapt the client registrar to the new thread-based implementation of QtDBus.

Alexandr Akulich kaffeine at kemper.freedesktop.org
Sat Aug 27 06:41:33 UTC 2016


Module: telepathy-qt
Branch: master
Commit: f496b0dbc0bc293b6a6714ddaa4d542aadc60c08
URL:    http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=f496b0dbc0bc293b6a6714ddaa4d542aadc60c08

Author: Gustavo Pichorim Boiko <gustavo.boiko at canonical.com>
Date:   Thu Aug 25 10:54:40 2016 -0300

Adapt the client registrar to the new thread-based implementation of QtDBus.

Starting with Qt 5.6.0 QtDBus is now thread-based and because of that calling
registerService() takes effect right away. So before exposing the clients on
DBus, make sure all the objects are already registered.

Reviewed-by: Alexandr Akulich <akulichalexander at gmail.com>

---

 TelepathyQt/client-registrar.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/TelepathyQt/client-registrar.cpp b/TelepathyQt/client-registrar.cpp
index 64905aa..9c647d0 100644
--- a/TelepathyQt/client-registrar.cpp
+++ b/TelepathyQt/client-registrar.cpp
@@ -903,8 +903,7 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
                 .arg((quintptr) client.data(), 0, 16));
     }
 
-    if (mPriv->services.contains(busName) ||
-        !mPriv->bus.registerService(busName)) {
+    if (mPriv->services.contains(busName)) {
         warning() << "Unable to register client: busName" <<
             busName << "already registered";
         return false;
@@ -950,7 +949,6 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
     if (interfaces.isEmpty()) {
         warning() << "Client does not implement any known interface";
         // cleanup
-        mPriv->bus.unregisterService(busName);
         return false;
     }
 
@@ -965,10 +963,18 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
             objectPath << "already registered";
         // cleanup
         delete object;
-        mPriv->bus.unregisterService(busName);
         return false;
     }
 
+    if (!mPriv->bus.registerService(busName)) {
+        warning() << "Unable to register service: busName" <<
+            busName << "already registered";
+        mPriv->bus.unregisterObject(objectPath, QDBusConnection::UnregisterTree);
+        delete object;
+        return false;
+    }
+
+
     if (handler) {
         handler->setRegistered(true);
     }



More information about the telepathy-commits mailing list