]> git.0d.be Git - empathy.git/commitdiff
Don't unnecessarily remove Individuals if Individual IDs have been reused
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 1 Sep 2010 13:59:03 +0000 (14:59 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 2 Sep 2010 14:01:30 +0000 (15:01 +0100)
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

index 1e76cbf834b0adbe7d0a7ef510dabc7416aa992d..15baa853810ef676a932999009410db5dde68c67 100644 (file)
@@ -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;