]> git.0d.be Git - empathy.git/commitdiff
empathy-chat: abort got_filtered_messages_cb if object was destroyed
authorDebarshi Ray <debarshir@src.gnome.org>
Thu, 7 Jun 2012 17:33:05 +0000 (19:33 +0200)
committerDebarshi Ray <debarshir@src.gnome.org>
Mon, 11 Jun 2012 11:03:03 +0000 (13:03 +0200)
Fixes: https://bugzilla.gnome.org/677641
libempathy-gtk/empathy-chat.c

index 18b08d480dc28eb621f8a45b379b593377aff36a..e6fd4538a3c8fec1f1d15eb075953cb0cc38e4e7 100644 (file)
@@ -2548,10 +2548,18 @@ got_filtered_messages_cb (GObject *manager,
 {
        GList *l;
        GList *messages;
 {
        GList *l;
        GList *messages;
-       EmpathyChat *chat = EMPATHY_CHAT (user_data);
-       EmpathyChatPriv *priv = GET_PRIV (chat);
+       TpWeakRef *wr = user_data;
+       EmpathyChat *chat = tp_weak_ref_dup_object (wr);
+       EmpathyChatPriv *priv;
        GError *error = NULL;
 
        GError *error = NULL;
 
+       if (chat == NULL) {
+               tp_weak_ref_destroy (wr);
+               return;
+       }
+
+       priv = GET_PRIV (chat);
+
        if (!tpl_log_manager_get_filtered_events_finish (TPL_LOG_MANAGER (manager),
                result, &messages, &error)) {
                DEBUG ("%s. Aborting.", error->message);
        if (!tpl_log_manager_get_filtered_events_finish (TPL_LOG_MANAGER (manager),
                result, &messages, &error)) {
                DEBUG ("%s. Aborting.", error->message);
@@ -2613,6 +2621,9 @@ out:
 
        /* Turn back on scrolling */
        empathy_chat_view_scroll (chat->view, TRUE);
 
        /* Turn back on scrolling */
        empathy_chat_view_scroll (chat->view, TRUE);
+
+       g_object_unref (chat);
+       tp_weak_ref_destroy (wr);
 }
 
 static void
 }
 
 static void
@@ -2643,7 +2654,7 @@ chat_add_logs (EmpathyChat *chat)
                                                   chat_log_filter,
                                                   chat,
                                                   got_filtered_messages_cb,
                                                   chat_log_filter,
                                                   chat,
                                                   got_filtered_messages_cb,
-                                                  (gpointer) chat);
+                                                  tp_weak_ref_new (chat, NULL, NULL));
 
        g_object_unref (target);
 }
 
        g_object_unref (target);
 }