]> git.0d.be Git - empathy.git/commitdiff
clear_chatrooms: prevent destroying the list twice
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 29 Apr 2011 08:10:28 +0000 (10:10 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 25 May 2011 07:22:42 +0000 (09:22 +0200)
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.

libempathy/empathy-chatroom-manager.c

index 212c5d8efd9ab31c281f45d8c7301dc55097ff44..2be475b3a2e26a1057b748c36cd1d7fee5a090b2 100644 (file)
@@ -424,9 +424,17 @@ static void
 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;
 
@@ -437,8 +445,7 @@ clear_chatrooms (EmpathyChatroomManager *self)
       g_object_unref (chatroom);
     }
 
-  g_list_free (priv->chatrooms);
-  priv->chatrooms = NULL;
+  g_list_free (tmp);
 }
 
 static void