diff options
-rw-r--r-- | libempathy/empathy-chatroom-manager.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index 212c5d8ef..2be475b3a 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -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 |