[empathy] Don't unnecessarily remove Individuals if Individual IDs have been reused



commit a4a6f1b83dcf33c57c0fca1a7f68735df05f888e
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Sep 1 14:59:03 2010 +0100

    Don't unnecessarily remove Individuals if Individual IDs have been reused
    
    When linking and unlinking, it's possible for the linked Individual to have
    the same ID as one of its component Individuals (before linked or once
    unlinked). If two such Individuals with the same ID are added and removed at
    the same time (as could [only] happen during linking or unlinking),
    EmpathyIndividualManager should do the Individual removals before the
    additions, in order to prevent one of the Individuals getting clobbered.
    Closes: bgo#627819

 libempathy/empathy-individual-manager.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index 1e76cbf..15baa85 100644
--- a/libempathy/empathy-individual-manager.c
+++ b/libempathy/empathy-individual-manager.c
@@ -173,6 +173,20 @@ aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator,
   EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
   GList *l, *added_filtered = NULL;
 
+  /* Handle the removals first, as one of the added Individuals might have the
+   * same ID as one of the removed Individuals (due to linking). */
+  for (l = removed; l; l = l->next)
+    {
+      FolksIndividual *ind = FOLKS_INDIVIDUAL (l->data);
+
+      g_signal_handlers_disconnect_by_func (ind,
+          individual_notify_personas_cb, self);
+
+      if (g_hash_table_lookup (priv->individuals,
+          folks_individual_get_id (ind)) != NULL)
+        remove_individual (self, ind);
+    }
+
   /* Filter the individuals for ones which contain EmpathyContacts */
   for (l = added; l; l = l->next)
     {
@@ -188,18 +202,6 @@ aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator,
         }
     }
 
-  for (l = removed; l; l = l->next)
-    {
-      FolksIndividual *ind = FOLKS_INDIVIDUAL (l->data);
-
-      g_signal_handlers_disconnect_by_func (ind,
-          individual_notify_personas_cb, self);
-
-      if (g_hash_table_lookup (priv->individuals,
-          folks_individual_get_id (ind)) != NULL)
-        remove_individual (self, ind);
-    }
-
   /* Bail if we have no individuals left */
   if (added_filtered == NULL && removed == NULL)
     return;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]