[glade/glade-3-12] Fixed bug #679487 "Huge memory leaks"



commit 4710f7f9e329bfb55db13031ae31f844b6d7a7ff
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Wed Jul 11 18:51:38 2012 -0300

    Fixed bug #679487 "Huge memory leaks"

 gladeui/glade-project.c |   26 ++++++++++----------------
 gladeui/glade-widget.c  |   22 ++++++++++++----------
 2 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index f16bd04..de17da0 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -2756,9 +2756,6 @@ glade_project_check_reordered (GladeProject *project,
                                GList        *old_order)
 {
   GList       *new_order, *l, *ll;
-  gint        *order, n_children, i;
-  GtkTreeIter  iter;
-  GtkTreePath *path;
 
   g_return_if_fail (GLADE_IS_PROJECT (project));
   g_return_if_fail (GLADE_IS_WIDGET (parent));
@@ -2770,7 +2767,7 @@ glade_project_check_reordered (GladeProject *project,
   /* Check if the list changed */
   for (l = old_order, ll = new_order; 
        l && ll; 
-       l = l->next, ll = ll->next)
+       l = g_list_next (l), ll = g_list_next (ll))
     {
       if (l->data != ll->data)
         break;
@@ -2778,23 +2775,20 @@ glade_project_check_reordered (GladeProject *project,
 
   if (l || ll)
     {
-      n_children = glade_project_count_children (project, parent);
-      order = g_new (gint, n_children);
+      gint *order = g_new0 (gint, g_list_length (new_order));
+      GtkTreePath *path;
+      GtkTreeIter iter;
+      gint i;
 
-      for (i = 0, l = new_order; l; l = l->next)
+      for (i = 0, l = new_order; l; l = g_list_next (l))
         {
           GObject *obj = l->data;
+          GList *node = g_list_find (old_order, obj);
 
-          if (glade_project_has_object (project, obj))
-            {
-              GList *node = g_list_find (old_order, obj);
-
-              g_assert (node);
-
-              order[i] = g_list_position (old_order, node);
+          g_assert (node);
 
-              i++;
-            }
+          order[i] = g_list_position (old_order, node);
+          i++;
         }
 
       /* Signal that the rows were reordered */
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 53226bd..bf6ae14 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -3216,19 +3216,22 @@ glade_widget_child_set_property (GladeWidget  *widget,
                                  const gchar  *property_name,
                                  const GValue *value)
 {
-  GList *old_order = NULL;
+  GladeWidgetPrivate *priv, *cpriv;
+  GList *old_order;
+  gboolean check;
 
   g_return_if_fail (GLADE_IS_WIDGET (widget));
   g_return_if_fail (GLADE_IS_WIDGET (child));
   g_return_if_fail (property_name != NULL && value != NULL);
 
-  if (widget->priv->project &&
-      widget->priv->in_project)
-    old_order = glade_widget_get_children (widget);
+  priv = widget->priv;
+  cpriv = child->priv;
 
-  glade_widget_adaptor_child_set_property (widget->priv->adaptor,
-                                           widget->priv->object,
-                                           child->priv->object, property_name, value);
+  check = priv->project && priv->in_project && cpriv->project && cpriv->in_project;
+  old_order = (check) ? glade_widget_get_children (widget) : NULL;
+
+  glade_widget_adaptor_child_set_property (priv->adaptor, priv->object,
+                                           cpriv->object, property_name, value);
 
   /* After setting a child property... it's possible the order of children
    * in the parent has been effected.
@@ -3237,9 +3240,8 @@ glade_widget_child_set_property (GladeWidget  *widget,
    * it's rows have been reordered so that any connected views update
    * themselves properly.
    */
-  if (widget->priv->project &&
-      widget->priv->in_project)
-    glade_project_check_reordered (widget->priv->project, widget, old_order);
+  if (check)
+    glade_project_check_reordered (priv->project, widget, old_order);
 
   g_list_free (old_order);
 }



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