clear_chatrooms (EmpathyChatroomManager *self)
{
EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
- GList *l;
+ GList *l, *tmp;
+
+ tmp = priv->chatrooms;
- for (l = priv->chatrooms; l != NULL; l = g_list_next (l))
+ /* Unreffing the chatroom may result in destroying the underlying
+ * EmpathyTpChat which will fire the invalidated signal and so make us
+ * re-call this function. We already set priv->chatrooms to NULL so we won't
+ * try to destroy twice the same objects. */
+ priv->chatrooms = NULL;
+
+ for (l = tmp; l != NULL; l = g_list_next (l))
{
EmpathyChatroom *chatroom = l->data;
g_object_unref (chatroom);
}
- g_list_free (priv->chatrooms);
- priv->chatrooms = NULL;
+ g_list_free (tmp);
}
static void