[telepathy-qt4/master] Channel: Make sure groupSelfContactRemoveInfo is set even if Closed is called before building the contacts.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Fri Jul 24 10:57:57 PDT 2009


---
 TelepathyQt4/channel.cpp |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/channel.cpp b/TelepathyQt4/channel.cpp
index 8dd37c9..36a72b2 100644
--- a/TelepathyQt4/channel.cpp
+++ b/TelepathyQt4/channel.cpp
@@ -855,9 +855,14 @@ void Channel::Private::updateContacts(const QList<ContactPtr> &contacts)
         GroupMemberChangeDetails details(
                 actorContact,
                 currentGroupMembersChangedInfo->details);
+
         if (currentGroupMembersChangedInfo->removed.contains(groupSelfHandle)) {
+            // Update groupSelfContactRemoveInfo with the proper actor in case
+            // the actor was not available by the time onMembersChangedDetailed
+            // was called.
             groupSelfContactRemoveInfo = details;
         }
+
         if (parent->isReady()) {
             // Channel is ready, we can signal membership changes to the outside world without
             // confusing anyone's fragile logic.
@@ -2401,6 +2406,17 @@ void Channel::onMembersChangedDetailed(
         return;
     }
 
+    // let's store groupSelfContactRemoveInfo here as we may not have time
+    // to build the contacts in case self contact is removed,
+    // as Closed will be emitted right after
+    if (removed.contains(mPriv->groupSelfHandle)) {
+        // let's try to get the actor contact from contact manager if available
+        mPriv->groupSelfContactRemoveInfo = GroupMemberChangeDetails(
+                mPriv->connection->contactManager()->lookupContactByHandle(
+                    qdbus_cast<uint>(details.value("actor"))),
+                details);
+    }
+
     mPriv->groupMembersChangedQueue.enqueue(
             new Private::GroupMembersChangedInfo(
                 added, removed,
-- 
1.5.6.5




More information about the telepathy-commits mailing list