[gnome-control-center] background: make sure the GnomeWPItems are freed.



commit 764f69e8525f8eb81f0457134c6d0b2e5ecc955a
Author: Thomas Wood <thomas wood intel com>
Date:   Wed Aug 11 15:37:41 2010 +0100

    background: make sure the GnomeWPItems are freed.
    
    Free the GnomeWPItems in the source liststore when the source is destroyed.

 panels/background/bg-source.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/panels/background/bg-source.c b/panels/background/bg-source.c
index f323c3c..9f130cc 100644
--- a/panels/background/bg-source.c
+++ b/panels/background/bg-source.c
@@ -20,6 +20,7 @@
  */
 
 #include "bg-source.h"
+#include "gnome-wp-item.h"
 
 G_DEFINE_ABSTRACT_TYPE (BgSource, bg_source, G_TYPE_OBJECT)
 
@@ -69,6 +70,22 @@ bg_source_set_property (GObject      *object,
     }
 }
 
+static gboolean
+free_tree_model_items (GtkTreeModel *model,
+                       GtkTreePath  *path,
+                       GtkTreeIter  *iter,
+                       gpointer      data)
+{
+  GnomeWPItem *item = NULL;
+
+  gtk_tree_model_get (model, iter, 1, &item, -1);
+
+  if (item)
+    gnome_wp_item_free (item);
+
+  return FALSE;
+}
+
 static void
 bg_source_dispose (GObject *object)
 {
@@ -76,6 +93,8 @@ bg_source_dispose (GObject *object)
 
   if (priv->store)
     {
+      gtk_tree_model_foreach (GTK_TREE_MODEL (priv->store),
+                              free_tree_model_items, NULL);
       g_object_unref (priv->store);
       priv->store = NULL;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]