From f496b0dbc0bc293b6a6714ddaa4d542aadc60c08 Mon Sep 17 00:00:00 2001 From: Gustavo Pichorim Boiko Date: Thu, 25 Aug 2016 10:54:40 -0300 Subject: [PATCH 4/4] 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 --- 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); } -- 1.9.3