[empathy/gnome-3-8] EmpathyNewChatroomDialog: Make sure we use the TpRoomList that correspond to selected account



commit 351ba3a165a5c8e74cca0f8160c399d9bb669e29
Author: Xavier Claessens <xavier claessens collabora co uk>
Date:   Mon Jun 10 17:09:19 2013 +0200

    EmpathyNewChatroomDialog: Make sure we use the TpRoomList that correspond to selected account
    
    When switching account  before tp_room_list_new_async() finish,
    there is a race for which one will finish first. We ignore the
    new TpRoomList if it does not correspond to the currently
    selected account.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698742

 src/empathy-new-chatroom-dialog.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index 5b9fa94..3ce59ab 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -496,16 +496,26 @@ new_room_list_cb (GObject *source,
     gpointer user_data)
 {
   EmpathyNewChatroomDialog *self = user_data;
+  TpRoomList *room_list;
   GError *error = NULL;
 
-  self->priv->room_list = tp_room_list_new_finish (result, &error);
-  if (self->priv->room_list == NULL)
+  room_list = tp_room_list_new_finish (result, &error);
+  if (room_list == NULL)
     {
       DEBUG ("Failed to create TpRoomList: %s\n", error->message);
       g_error_free (error);
       return;
     }
 
+  if (tp_room_list_get_account (room_list) != self->priv->account)
+    {
+      /* Account changed while we were creating this TpRoomList */
+      g_object_unref (room_list);
+      return;
+    }
+
+  self->priv->room_list = room_list;
+
   tp_g_signal_connect_object (self->priv->room_list, "got-room",
       G_CALLBACK (new_chatroom_dialog_got_room_cb), self, 0);
   tp_g_signal_connect_object (self->priv->room_list, "failed",
@@ -529,7 +539,6 @@ new_room_list_cb (GObject *source,
   gtk_widget_set_sensitive (self->priv->expander_browse, TRUE);
 
   new_chatroom_dialog_update_widgets (self);
-
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]