]> git.0d.be Git - empathy.git/commitdiff
Don't create an unused hashtable and free location on finalize
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 9 May 2009 20:14:26 +0000 (16:14 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 9 May 2009 21:22:23 +0000 (17:22 -0400)
libempathy/empathy-contact.c

index 87b66a074343d56181240632f9c70ffbc889a93f..6c7b18c4f516cee4c4ab65196088d9b48a923485 100644 (file)
@@ -262,9 +262,7 @@ empathy_contact_init (EmpathyContact *contact)
 
   contact->priv = priv;
 
 
   contact->priv = priv;
 
-  priv->location = g_hash_table_new_full (g_str_hash, g_str_equal,
-                       (GDestroyNotify) g_free,
-                       (GDestroyNotify) tp_g_value_slice_free);
+  priv->location = NULL;
 }
 
 static void
 }
 
 static void
@@ -283,6 +281,9 @@ contact_finalize (GObject *object)
   if (priv->avatar)
       empathy_avatar_unref (priv->avatar);
 
   if (priv->avatar)
       empathy_avatar_unref (priv->avatar);
 
+  if (priv->location != NULL)
+      g_hash_table_unref (priv->location);
+
   G_OBJECT_CLASS (empathy_contact_parent_class)->finalize (object);
 }
 
   G_OBJECT_CLASS (empathy_contact_parent_class)->finalize (object);
 }
 
@@ -1034,7 +1035,7 @@ empathy_avatar_save_to_file (EmpathyAvatar *self,
  * Example: a "city" key would have "Helsinki" as string GValue,
  *          a "latitude" would have 65.0 as double GValue.
  *
  * Example: a "city" key would have "Helsinki" as string GValue,
  *          a "latitude" would have 65.0 as double GValue.
  *
- * Returns: a #GHashTable of location values
+ * Returns: a #GHashTable of location values, use #g_hash_table_unref when it to free it
  */
 GHashTable *
 empathy_contact_get_location (EmpathyContact *contact)
  */
 GHashTable *
 empathy_contact_get_location (EmpathyContact *contact)
@@ -1070,7 +1071,8 @@ empathy_contact_set_location (EmpathyContact *contact,
 
   priv = GET_PRIV (contact);
 
 
   priv = GET_PRIV (contact);
 
-  g_hash_table_unref (priv->location);
+  if (priv->location != NULL)
+    g_hash_table_unref (priv->location);
 
   priv->location = g_hash_table_ref (location);
   g_object_notify (G_OBJECT (contact), "location");
 
   priv->location = g_hash_table_ref (location);
   g_object_notify (G_OBJECT (contact), "location");