]> git.0d.be Git - empathy.git/commitdiff
individual-widget: connect on the notify::client-types only once
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 1 Feb 2011 10:34:37 +0000 (11:34 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 1 Feb 2011 10:34:37 +0000 (11:34 +0100)
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

index 2f7899b2bcd189db7511c62b989e7a0becdba575..6cb6226a52156b9385582f00515f161c76fd068d 100644 (file)
@@ -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;