[gtk+/gtk-3-14] GtkFontChooserWidget: Plug several memleaks



commit 30a1c4ab359e7c285bf408f0de73ef3b911f52d3
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 14 23:59:25 2014 -0400

    GtkFontChooserWidget: Plug several memleaks
    
    These were showing up in valgrind.

 gtk/gtkfontchooserwidget.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index f184316..14171f3 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -819,6 +819,7 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column,
   pango_font_description_free (font_desc);
   pango_attr_list_unref (attrs);
   g_free (text);
+  g_free (preview_title);
 }
 
 static void
@@ -860,6 +861,8 @@ gtk_font_chooser_widget_finalize (GObject *object)
   if (priv->filter_data_destroy)
     priv->filter_data_destroy (priv->filter_data);
 
+  g_free (priv->preview_text);
+
   G_OBJECT_CLASS (gtk_font_chooser_widget_parent_class)->finalize (object);
 }
 
@@ -879,13 +882,14 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget        *fontchooser,
   GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
   PangoFontDescription *desc;
   PangoFontFamily *family;
-  gboolean valid;
+  gboolean valid, found;
 
   if (pango_font_description_get_family (font_desc) == NULL)
     return FALSE;
 
+  found = FALSE;
   for (valid = gtk_tree_model_get_iter_first (priv->model, iter);
-       valid;
+       valid && !found;
        valid = gtk_tree_model_iter_next (priv->model, iter))
     {
       gtk_tree_model_get (priv->model, iter,
@@ -900,12 +904,12 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget        *fontchooser,
 
       pango_font_description_merge_static (desc, font_desc, FALSE);
       if (pango_font_description_equal (desc, font_desc))
-        break;
+        found = TRUE;
 
       pango_font_description_free (desc);
     }
   
-  return valid;
+  return found;
 }
 
 static void


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