]> git.0d.be Git - empathy.git/commitdiff
EmpathyContact keeps a ref to the factory.
authorXavier Claessens <xclaesse@src.gnome.org>
Mon, 12 Jan 2009 21:51:26 +0000 (21:51 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Mon, 12 Jan 2009 21:51:26 +0000 (21:51 +0000)
svn path=/trunk/; revision=2228

libempathy/empathy-contact.c

index 437b726bbd1f774871a21372ebb707a582451c67..0b7a1401d651eae61246e5555fe581cafbdc3a29 100644 (file)
@@ -34,6 +34,7 @@
 #include <libmissioncontrol/mc-enum-types.h>
 
 #include "empathy-contact.h"
+#include "empathy-contact-factory.h"
 #include "empathy-utils.h"
 #include "empathy-enum-types.h"
 #include "empathy-marshal.h"
@@ -43,6 +44,7 @@
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
 typedef struct {
+  EmpathyContactFactory *factory;
   gchar *id;
   gchar *name;
   EmpathyAvatar *avatar;
@@ -95,6 +97,22 @@ enum {
 
 static guint signals[LAST_SIGNAL];
 
+static void
+contact_dispose (GObject *object)
+{
+  EmpathyContactPriv *priv = GET_PRIV (object);
+
+  if (priv->account)
+    g_object_unref (priv->account);
+  priv->account = NULL;
+
+  if (priv->factory)
+    g_object_unref (priv->factory);
+  priv->factory = NULL;
+
+  G_OBJECT_CLASS (empathy_contact_parent_class)->dispose (object);
+}
+
 static void
 empathy_contact_class_init (EmpathyContactClass *class)
 {
@@ -103,6 +121,7 @@ empathy_contact_class_init (EmpathyContactClass *class)
   object_class = G_OBJECT_CLASS (class);
 
   object_class->finalize = contact_finalize;
+  object_class->dispose = contact_dispose;
   object_class->get_property = contact_get_property;
   object_class->set_property = contact_set_property;
 
@@ -213,6 +232,10 @@ empathy_contact_init (EmpathyContact *contact)
     EMPATHY_TYPE_CONTACT, EmpathyContactPriv);
 
   contact->priv = priv;
+
+  /* Keep a ref to the factory to be sure it is not finalized while there is
+   * still contacts alive. */
+  priv->factory = empathy_contact_factory_dup_singleton ();
 }
 
 static void
@@ -244,9 +267,6 @@ contact_finalize (GObject *object)
   if (priv->avatar)
       empathy_avatar_unref (priv->avatar);
 
-  if (priv->account)
-      g_object_unref (priv->account);
-
   G_OBJECT_CLASS (empathy_contact_parent_class)->finalize (object);
 }