]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-individual-manager.c
Don't unnecessarily remove Individuals if Individual IDs have been reused
[empathy.git] / 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;