From 9503c4aa28b9a4215e3e325a31b500f2c78b712a Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 1 Feb 2011 11:34:37 +0100 Subject: individual-widget: connect on the notify::client-types only once Reconnecting a signal while you are handling it isn't exactly a good idea as it will result in an infinite loop eating all your memory (#635105). --- libempathy-gtk/empathy-individual-widget.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-individual-widget.c b/libempathy-gtk/empathy-individual-widget.c index 2f7899b2b..6cb6226a5 100644 --- a/libempathy-gtk/empathy-individual-widget.c +++ b/libempathy-gtk/empathy-individual-widget.c @@ -199,6 +199,14 @@ contact_info_field_cmp (TpContactInfoField *field1, return contact_info_field_name_cmp (field1->field_name, field2->field_name); } +static void +client_types_notify_cb (TpContact *contact, + GParamSpec *pspec, + EmpathyIndividualWidget *self) +{ + client_types_update (self); +} + static void update_weak_contact (EmpathyIndividualWidget *self) { @@ -244,6 +252,9 @@ update_weak_contact (EmpathyIndividualWidget *self) priv->contact = tp_contact; g_object_add_weak_pointer (G_OBJECT (tp_contact), (gpointer *) &priv->contact); + + g_signal_connect (priv->contact, "notify::client-types", + (GCallback) client_types_notify_cb, self); } } @@ -809,14 +820,6 @@ location_update (EmpathyIndividualWidget *self) gtk_widget_show (priv->vbox_location); } -static void -client_types_notify_cb (TpContact *contact, - GParamSpec *pspec, - EmpathyIndividualWidget *self) -{ - client_types_update (self); -} - static void client_types_update (EmpathyIndividualWidget *self) { @@ -850,8 +853,6 @@ client_types_update (EmpathyIndividualWidget *self) gtk_widget_hide (priv->hbox_client_types); } - g_signal_connect (priv->contact, "notify::client-types", - (GCallback) client_types_notify_cb, self); } static void @@ -862,6 +863,9 @@ remove_weak_contact (EmpathyIndividualWidget *self) if (priv->contact == NULL) return; + g_signal_handlers_disconnect_by_func (priv->contact, client_types_notify_cb, + self); + g_object_remove_weak_pointer (G_OBJECT (priv->contact), (gpointer *) &priv->contact); priv->contact = NULL; -- cgit v1.2.3