]> git.0d.be Git - empathy.git/commitdiff
Take advantage of the tp_clear_* utility functions.
authorTravis Reitter <treitter@gmail.com>
Thu, 8 Jul 2010 03:16:46 +0000 (20:16 -0700)
committerTravis Reitter <treitter@gmail.com>
Tue, 20 Jul 2010 23:12:36 +0000 (16:12 -0700)
libempathy-gtk/empathy-individual-store.c
libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-ui-utils.c
libempathy/empathy-individual-manager.c

index 87fa80083b036f1d41f08e3d86706dbd743bb47b..4a3b686534762907bc006d46ed8bf837dec16abd 100644 (file)
@@ -269,10 +269,7 @@ individual_store_find_contact_foreach (GtkTreeModel *model,
       fc->iters = g_list_append (fc->iters, gtk_tree_iter_copy (iter));
     }
 
-  if (individual != NULL)
-    {
-      g_object_unref (individual);
-    }
+  tp_clear_object (&individual);
 
   return FALSE;
 }
@@ -1271,16 +1268,8 @@ individual_store_state_sort_func (GtkTreeModel *model,
 free_and_out:
   g_free (name_a);
   g_free (name_b);
-
-  if (individual_a)
-    {
-      g_object_unref (individual_a);
-    }
-
-  if (individual_b)
-    {
-      g_object_unref (individual_b);
-    }
+  tp_clear_object (&individual_a);
+  tp_clear_object (&individual_b);
 
   return ret_val;
 }
@@ -1314,15 +1303,8 @@ individual_store_name_sort_func (GtkTreeModel *model,
   else
     ret_val = individual_store_contact_sort (individual_a, individual_b);
 
-  if (individual_a)
-    {
-      g_object_unref (individual_a);
-    }
-
-  if (individual_b)
-    {
-      g_object_unref (individual_b);
-    }
+  tp_clear_object (&individual_a);
+  tp_clear_object (&individual_b);
 
   return ret_val;
 }
index dc90990189aab83286c378fc7d69a9c2014eb92d..bab8b1dfda9404f0fd04049195020537890e0737 100644 (file)
@@ -1011,10 +1011,7 @@ individual_view_pixbuf_cell_data_func (GtkTreeViewColumn *tree_column,
       "pixbuf", pixbuf,
       NULL);
 
-  if (pixbuf != NULL)
-    {
-      g_object_unref (pixbuf);
-    }
+  tp_clear_object (&pixbuf);
 
   individual_view_cell_set_background (view, cell, is_group, is_active);
 }
@@ -1054,8 +1051,7 @@ out:
       "pixbuf", pixbuf,
       NULL);
 
-  if (pixbuf != NULL)
-    g_object_unref (pixbuf);
+  tp_clear_object (&pixbuf);
 
   g_free (name);
 }
@@ -1108,10 +1104,7 @@ individual_view_avatar_cell_data_func (GtkTreeViewColumn *tree_column,
       "pixbuf", pixbuf,
       NULL);
 
-  if (pixbuf)
-    {
-      g_object_unref (pixbuf);
-    }
+  tp_clear_object (&pixbuf);
 
   individual_view_cell_set_background (view, cell, is_group, is_active);
 }
@@ -1683,26 +1676,10 @@ individual_view_dispose (GObject *object)
   EmpathyIndividualView *view = EMPATHY_INDIVIDUAL_VIEW (object);
   EmpathyIndividualViewPriv *priv = GET_PRIV (view);
 
-  if (priv->store != NULL)
-    {
-      g_object_unref (priv->store);
-      priv->store = NULL;
-    }
-  if (priv->filter != NULL)
-    {
-      g_object_unref (priv->filter);
-      priv->filter = NULL;
-    }
-  if (priv->tooltip_widget != NULL)
-    {
-      gtk_widget_destroy (priv->tooltip_widget);
-      priv->tooltip_widget = NULL;
-    }
-  if (priv->file_targets != NULL)
-    {
-      gtk_target_list_unref (priv->file_targets);
-      priv->file_targets = NULL;
-    }
+  tp_clear_object (&priv->store);
+  tp_clear_object (&priv->filter);
+  tp_clear_pointer (&priv->tooltip_widget, gtk_widget_destroy);
+  tp_clear_pointer (&priv->file_targets, gtk_target_list_unref);
 
   empathy_individual_view_set_live_search (view, NULL);
 
index 9b984a7ce441ad879ffd78eb7e1d8cc115d0e842..15b5871c67e25db27d78ced65c00884b6704b85b 100644 (file)
@@ -39,6 +39,7 @@
 #include <gtk/gtk.h>
 #include <gio/gio.h>
 
+#include <telepathy-glib/util.h>
 #include <folks/folks.h>
 
 #include "empathy-ui-utils.h"
@@ -606,8 +607,7 @@ avatar_file_load_contents_cb (GObject      *object,
 out:
        g_clear_error (&error);
        g_free (data);
-       if (loader != NULL)
-               g_object_unref (loader);
+       tp_clear_object (&loader);
        pixbuf_avatar_from_individual_closure_free (closure);
 }
 
index 183996a3d946480c0555e3b6a3d37845935d92f9..a86ec01479715c281abd23870171e775005c65e5 100644 (file)
@@ -121,11 +121,8 @@ individual_manager_finalize (GObject *object)
 {
   EmpathyIndividualManagerPriv *priv = GET_PRIV (object);
 
-  if (priv->contact_manager != NULL)
-    g_object_unref (priv->contact_manager);
-
-  if (priv->aggregator != NULL)
-    g_object_unref (priv->aggregator);
+  tp_clear_object (&priv->contact_manager);
+  tp_clear_object (&priv->aggregator);
 }
 
 static GObject *