]> git.0d.be Git - empathy.git/commitdiff
Do not unref tp_chat directly in the message_received callback to avoid a crash.
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 9 May 2008 08:06:22 +0000 (08:06 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 9 May 2008 08:06:22 +0000 (08:06 +0000)
svn path=/trunk/; revision=1097

src/empathy-status-icon.c

index bd18b2d28318e2356f377caf32193dac9d468a8e..f33447033d581aa8dd31abc5e65ad95fd3dd290c 100644 (file)
@@ -368,6 +368,13 @@ status_icon_channel_process (EmpathyStatusIcon *icon,
        g_object_unref (channel);
 }
 
+static gboolean
+status_icon_chat_unref_idle (gpointer user_data)
+{
+       g_object_unref (user_data);
+       return FALSE;
+}
+
 static void
 status_icon_chat_message_received_cb (EmpathyTpChat     *tp_chat,
                                      EmpathyMessage    *message,
@@ -377,6 +384,11 @@ status_icon_chat_message_received_cb (EmpathyTpChat     *tp_chat,
        gchar           *msg;
        TpChannel       *channel;
 
+       g_idle_add (status_icon_chat_unref_idle, tp_chat);
+       g_signal_handlers_disconnect_by_func (tp_chat,
+                                             status_icon_chat_message_received_cb,
+                                             icon);
+
        sender = empathy_message_get_sender (message);
        msg = g_strdup_printf (_("New message from %s:\n%s"),
                               empathy_contact_get_name (sender),
@@ -388,7 +400,6 @@ status_icon_chat_message_received_cb (EmpathyTpChat     *tp_chat,
                               g_object_ref (channel));
 
        g_free (msg);
-       g_object_unref (tp_chat);
 }
 
 static void