[Telepathy-commits] [telepathy-qt4/master] Don't uselesslesly call HoldHandles when all handles are already held and double-finish when the useless call returns

Olli Salli olli.salli at collabora.co.uk
Wed Jan 21 04:42:17 PST 2009


---
 TelepathyQt4/cli-connection.cpp      |   15 +++++++++++----
 TelepathyQt4/cli-pending-handles.cpp |    5 +++++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/TelepathyQt4/cli-connection.cpp b/TelepathyQt4/cli-connection.cpp
index 34fd216..3ab5cc9 100644
--- a/TelepathyQt4/cli-connection.cpp
+++ b/TelepathyQt4/cli-connection.cpp
@@ -611,11 +611,18 @@ PendingHandles* Connection::referenceHandles(uint handleType, const UIntList& ha
 
     PendingHandles* pending =
         new PendingHandles(this, handleType, handles, alreadyHeld);
-    QDBusPendingCallWatcher* watcher =
-        new QDBusPendingCallWatcher(mPriv->baseInterface->HoldHandles(handleType, notYetHeld), pending);
 
-    pending->connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
-                              SLOT(onCallFinished(QDBusPendingCallWatcher*)));
+    if (!notYetHeld.isEmpty()) {
+        debug() << " Calling HoldHandles";
+
+        QDBusPendingCallWatcher* watcher =
+            new QDBusPendingCallWatcher(mPriv->baseInterface->HoldHandles(handleType, notYetHeld), pending);
+
+        pending->connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+                                  SLOT(onCallFinished(QDBusPendingCallWatcher*)));
+    } else {
+        debug() << " All handles already held, not calling HoldHandles";
+    }
 
     return pending;
 }
diff --git a/TelepathyQt4/cli-pending-handles.cpp b/TelepathyQt4/cli-pending-handles.cpp
index fcd76a2..b9a4ca5 100644
--- a/TelepathyQt4/cli-pending-handles.cpp
+++ b/TelepathyQt4/cli-pending-handles.cpp
@@ -44,6 +44,8 @@ struct PendingHandles::Private
 PendingHandles::PendingHandles(Connection* connection, uint handleType, const QStringList& names)
     : PendingOperation(connection), mPriv(new Private)
 {
+    debug() << "PendingHandles(request)";
+
     mPriv->connection = connection;
     mPriv->handleType = handleType;
     mPriv->isRequest = true;
@@ -53,6 +55,8 @@ PendingHandles::PendingHandles(Connection* connection, uint handleType, const QS
 PendingHandles::PendingHandles(Connection* connection, uint handleType, const UIntList& handles, const UIntList& alreadyHeld)
     : PendingOperation(connection), mPriv(new Private)
 {
+    debug() << "PendingHandles(reference)";
+
     mPriv->connection = connection;
     mPriv->handleType = handleType;
     mPriv->isRequest = false;
@@ -60,6 +64,7 @@ PendingHandles::PendingHandles(Connection* connection, uint handleType, const UI
     mPriv->alreadyHeld = ReferencedHandles(connection, handleType, alreadyHeld);
 
     if (alreadyHeld == handles) {
+        debug() << " All handles already held, finishing up instantly";
         mPriv->handles = mPriv->alreadyHeld;
         setFinished();
     }
-- 
1.5.6.5




More information about the Telepathy-commits mailing list