From ee2b89a5cbd5b5837488c7334a259bc356eccdc4 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 2 Oct 2012 13:47:27 +0200 Subject: cope with the top_group_members list being changed while iterating over it https://bugzilla.gnome.org/show_bug.cgi?id=685203 --- libempathy-gtk/empathy-roster-model-manager.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libempathy-gtk/empathy-roster-model-manager.c b/libempathy-gtk/empathy-roster-model-manager.c index bd3eeeb00..859edb7a9 100644 --- a/libempathy-gtk/empathy-roster-model-manager.c +++ b/libempathy-gtk/empathy-roster-model-manager.c @@ -195,15 +195,22 @@ top_individuals_changed_cb (EmpathyIndividualManager *manager, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP, TRUE); } } - for (l = self->priv->top_group_members; l != NULL; l = g_list_next (l)) + + l = self->priv->top_group_members; + while (l != NULL) { - if (!individual_should_be_in_top_group_members (self, l->data)) + FolksIndividual *individual = l->data; + + /* remove_from_top_group_members will modify the list so we already take + * the next pointer. */ + l = g_list_next (l); + + if (!individual_should_be_in_top_group_members (self, individual)) { - remove_from_top_group_members (self, l->data); + remove_from_top_group_members (self, individual); - empathy_roster_model_fire_groups_changed ( - EMPATHY_ROSTER_MODEL (self), l->data, - EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP, FALSE); + empathy_roster_model_fire_groups_changed (EMPATHY_ROSTER_MODEL (self), + individual, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP, FALSE); } } } -- cgit v1.2.3