[glade/offscreen-design-layout] * gladeui/glade-project.c, gladeui/glade-property-class.c, gladeui/glade-widget-adaptor.c, gladeui



commit ac2a9d01e8cd4cb3bfa9683f2716fcb7fa409ff1
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Jan 16 22:54:15 2011 +0900

    	* gladeui/glade-project.c, gladeui/glade-property-class.c, gladeui/glade-widget-adaptor.c,
    	gladeui/glade-widget.c, plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-model-data.c:
    	Plugged more leaks found with valgrind.

 ChangeLog                       |    4 ++++
 gladeui/glade-project.c         |    6 +++++-
 gladeui/glade-property-class.c  |    4 ++--
 gladeui/glade-widget-adaptor.c  |    3 +++
 gladeui/glade-widget.c          |   11 +++--------
 plugins/gtk+/glade-gtk.c        |   30 +++++++++++++++++++-----------
 plugins/gtk+/glade-model-data.c |   12 ++++++++----
 7 files changed, 44 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3ab1833..e908957 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,10 @@
 	* gladeui/glade-builtins.c: Removed _() annotations for strings that dont need to be
 	translated.
 
+	* gladeui/glade-project.c, gladeui/glade-property-class.c, gladeui/glade-widget-adaptor.c,
+	gladeui/glade-widget.c, plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-model-data.c:
+	Plugged more leaks found with valgrind.
+
 2011-01-15  Emilio Pozuelo Monfort <pochu27 gmail com>
 
 	* plugins/gtk+/Makefile.am: Don't install .in files.
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 2f2f15a..41dc18b 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -345,7 +345,6 @@ glade_project_finalize (GObject * object)
   GList *list;
   TopLevelInfo *tinfo;
 
-  /* XXX FIXME: Destroy dialog related sizegroups here... */
   gtk_widget_destroy (project->priv->prefs_dialog);
 
   g_free (project->priv->path);
@@ -4245,6 +4244,11 @@ glade_project_build_prefs_box (GladeProject * project)
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
   gtk_size_group_add_widget (sizegroup3, hbox);
 
+  /* Pass ownership to the widgets in the groups */
+  g_object_unref (sizegroup1);
+  g_object_unref (sizegroup2);
+  g_object_unref (sizegroup3);
+
   update_prefs_for_resource_path (project);
 
   g_signal_connect (G_OBJECT (project->priv->resource_default_radio), "toggled",
diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c
index a037c77..44aa62e 100644
--- a/gladeui/glade-property-class.c
+++ b/gladeui/glade-property-class.c
@@ -810,7 +810,7 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *
           g_value_set_static_string (&str_value, strv[i]);
           value_array = g_value_array_append (value_array, &str_value);
         }
-      g_value_set_boxed (value, value_array);
+      g_value_take_boxed (value, value_array);
       g_strfreev (strv);
     }
   else if (G_IS_PARAM_SPEC_BOXED (property_class->pspec))
@@ -869,7 +869,7 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *
     {
       GList *objects = glade_property_class_make_objects_from_string
           (property_class, string, project, widget);
-      g_value_set_boxed (value, objects);
+      g_value_take_boxed (value, objects);
     }
   else
     g_critical ("Unsupported pspec type %s (string -> value)",
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index d827a2c..2220ba5 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -911,7 +911,10 @@ glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor * adaptor,
       if (!(signal = glade_signal_read (iter_node, adaptor)))
         continue;
 
+      /* The widget doesnt use the signal handler directly but rather
+       * creates it's own copy */
       glade_widget_add_signal_handler (widget, signal);
+      g_object_unref (signal);
     }
 
   /* Read in children */
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 4a43ab4..1beb68d 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -318,7 +318,7 @@ glade_widget_add_signal_handler (GladeWidget *widget, const GladeSignal *signal_
   signals = glade_widget_list_signal_handlers (widget, glade_signal_get_name (signal_handler));
   if (!signals)
     {
-      signals = g_ptr_array_new ();
+      signals = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
       g_hash_table_insert (widget->priv->signals, 
 			   g_strdup (glade_signal_get_name (signal_handler)),
                            signals);
@@ -1143,14 +1143,9 @@ glade_widget_get_real_property (GObject * object,
 }
 
 static void
-free_signals (gpointer value)
+free_signals (GPtrArray *signals)
 {
-  GPtrArray *signals = (GPtrArray *) value;
-
-  if (signals == NULL)
-    return;
-
-  g_ptr_array_foreach (signals, (GFunc) g_object_unref, NULL);
+  g_assert (signals);
   g_ptr_array_free (signals, TRUE);
 }
 
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 4a3b16b..31996b5 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -2477,6 +2477,9 @@ glade_gtk_table_widget_exceeds_bounds (GtkTable * table, gint n_rows,
           break;
         }
     }
+
+  g_list_free (children);
+
   return ret;
 }
 
@@ -10266,10 +10269,16 @@ glade_gtk_store_read_columns (GladeWidget * widget, GladeXmlNode * node)
       type =
           glade_xml_get_property_string_required (prop, GLADE_TAG_TYPE, NULL);
 
-      data = glade_column_type_new (type, NULL);
-      data->type_name = g_strdup (type);
-      data->column_name =
-          column_name[0] ? g_strdup (column_name) : g_ascii_strdown (type, -1);
+      if (!column_name[0])
+	{
+	  gchar *cname = g_ascii_strdown (type, -1);
+
+	  data = glade_column_type_new (type, cname);
+
+	  g_free (cname);
+	}
+      else
+	data = glade_column_type_new (type, column_name);
 
       if (glade_name_context_has_name (context, data->column_name))
         {
@@ -10286,6 +10295,8 @@ glade_gtk_store_read_columns (GladeWidget * widget, GladeXmlNode * node)
       column_name[0] = '\0';
     }
 
+  glade_name_context_destroy (context);
+
   property = glade_widget_get_property (widget, "columns");
   g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
   g_value_take_boxed (&value, g_list_reverse (types));
@@ -10368,15 +10379,12 @@ glade_gtk_store_read_data (GladeWidget * widget, GladeXmlNode * node)
                * should we be doing this part in "finished" ? ... todo thinkso...
                */
               value_str = glade_xml_get_content (col_node);
-              value = glade_utils_value_from_string
-		(g_type_from_name (column_type->type_name), value_str,
-                   glade_widget_get_project (widget), widget);
+              value = glade_utils_value_from_string (g_type_from_name (column_type->type_name), value_str,
+						     glade_widget_get_project (widget), widget);
               g_free (value_str);
 
-              data =
-                  glade_model_data_new (g_type_from_name
-                                        (column_type->type_name),
-                                        column_type->column_name);
+              data = glade_model_data_new (g_type_from_name (column_type->type_name),
+					   column_type->column_name);
 
               g_value_copy (value, &data->value);
               g_value_unset (value);
diff --git a/plugins/gtk+/glade-model-data.c b/plugins/gtk+/glade-model-data.c
index 3e2f529..dce7436 100644
--- a/plugins/gtk+/glade-model-data.c
+++ b/plugins/gtk+/glade-model-data.c
@@ -33,7 +33,7 @@
 GladeModelData *
 glade_model_data_new (GType type, const gchar * column_name)
 {
-  GladeModelData *data = g_new0 (GladeModelData, 1);
+  GladeModelData *data = g_slice_new0 (GladeModelData);
 
   if (type != 0)
     g_value_init (&data->value, type);
@@ -49,10 +49,12 @@ glade_model_data_new (GType type, const gchar * column_name)
 GladeModelData *
 glade_model_data_copy (GladeModelData * data)
 {
+  GladeModelData *dup;
+
   if (!data)
     return NULL;
 
-  GladeModelData *dup = g_new0 (GladeModelData, 1);
+  dup = g_slice_new0 (GladeModelData);
 
   if (G_VALUE_TYPE (&data->value) != 0)
     {
@@ -80,7 +82,7 @@ glade_model_data_free (GladeModelData * data)
       g_free (data->name);
       g_free (data->i18n_context);
       g_free (data->i18n_comment);
-      g_free (data);
+      g_slice_free (GladeModelData, data);
     }
 }
 
@@ -90,10 +92,12 @@ glade_model_data_tree_copy (GNode * node)
   return g_node_copy_deep (node, (GCopyFunc) glade_model_data_copy, NULL);
 }
 
-static void
+static gboolean
 model_data_traverse_free (GNode * node, gpointer data)
 {
   glade_model_data_free ((GladeModelData *) node->data);
+
+  return FALSE;
 }
 
 void



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