Blame 0004-Adapt-the-client-registrar-to-the-new-thread-based-i.patch

Rex Dieter c0bdaa6
From f496b0dbc0bc293b6a6714ddaa4d542aadc60c08 Mon Sep 17 00:00:00 2001
Rex Dieter c0bdaa6
From: Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
Rex Dieter c0bdaa6
Date: Thu, 25 Aug 2016 10:54:40 -0300
Rex Dieter c0bdaa6
Subject: [PATCH 4/4] Adapt the client registrar to the new thread-based
Rex Dieter c0bdaa6
 implementation of QtDBus.
Rex Dieter c0bdaa6
Rex Dieter c0bdaa6
Starting with Qt 5.6.0 QtDBus is now thread-based and because of that calling
Rex Dieter c0bdaa6
registerService() takes effect right away. So before exposing the clients on
Rex Dieter c0bdaa6
DBus, make sure all the objects are already registered.
Rex Dieter c0bdaa6
Rex Dieter c0bdaa6
Reviewed-by: Alexandr Akulich <akulichalexander@gmail.com>
Rex Dieter c0bdaa6
---
Rex Dieter c0bdaa6
 TelepathyQt/client-registrar.cpp | 14 ++++++++++----
Rex Dieter c0bdaa6
 1 file changed, 10 insertions(+), 4 deletions(-)
Rex Dieter c0bdaa6
Rex Dieter c0bdaa6
diff --git a/TelepathyQt/client-registrar.cpp b/TelepathyQt/client-registrar.cpp
Rex Dieter c0bdaa6
index 64905aa..9c647d0 100644
Rex Dieter c0bdaa6
--- a/TelepathyQt/client-registrar.cpp
Rex Dieter c0bdaa6
+++ b/TelepathyQt/client-registrar.cpp
Rex Dieter c0bdaa6
@@ -903,8 +903,7 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
Rex Dieter c0bdaa6
                 .arg((quintptr) client.data(), 0, 16));
Rex Dieter c0bdaa6
     }
Rex Dieter c0bdaa6
 
Rex Dieter c0bdaa6
-    if (mPriv->services.contains(busName) ||
Rex Dieter c0bdaa6
-        !mPriv->bus.registerService(busName)) {
Rex Dieter c0bdaa6
+    if (mPriv->services.contains(busName)) {
Rex Dieter c0bdaa6
         warning() << "Unable to register client: busName" <<
Rex Dieter c0bdaa6
             busName << "already registered";
Rex Dieter c0bdaa6
         return false;
Rex Dieter c0bdaa6
@@ -950,7 +949,6 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
Rex Dieter c0bdaa6
     if (interfaces.isEmpty()) {
Rex Dieter c0bdaa6
         warning() << "Client does not implement any known interface";
Rex Dieter c0bdaa6
         // cleanup
Rex Dieter c0bdaa6
-        mPriv->bus.unregisterService(busName);
Rex Dieter c0bdaa6
         return false;
Rex Dieter c0bdaa6
     }
Rex Dieter c0bdaa6
 
Rex Dieter c0bdaa6
@@ -965,10 +963,18 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
Rex Dieter c0bdaa6
             objectPath << "already registered";
Rex Dieter c0bdaa6
         // cleanup
Rex Dieter c0bdaa6
         delete object;
Rex Dieter c0bdaa6
-        mPriv->bus.unregisterService(busName);
Rex Dieter c0bdaa6
         return false;
Rex Dieter c0bdaa6
     }
Rex Dieter c0bdaa6
 
Rex Dieter c0bdaa6
+    if (!mPriv->bus.registerService(busName)) {
Rex Dieter c0bdaa6
+        warning() << "Unable to register service: busName" <<
Rex Dieter c0bdaa6
+            busName << "already registered";
Rex Dieter c0bdaa6
+        mPriv->bus.unregisterObject(objectPath, QDBusConnection::UnregisterTree);
Rex Dieter c0bdaa6
+        delete object;
Rex Dieter c0bdaa6
+        return false;
Rex Dieter c0bdaa6
+    }
Rex Dieter c0bdaa6
+
Rex Dieter c0bdaa6
+
Rex Dieter c0bdaa6
     if (handler) {
Rex Dieter c0bdaa6
         handler->setRegistered(true);
Rex Dieter c0bdaa6
     }
Rex Dieter c0bdaa6
-- 
Rex Dieter c0bdaa6
1.9.3
Rex Dieter c0bdaa6