[gtk+/gtk-3-14] Return correct font from gtk_font_chooser_widget_find_font
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] Return correct font from gtk_font_chooser_widget_find_font
- Date: Mon, 27 Oct 2014 01:58:10 +0000 (UTC)
commit fe6b3e552edd21cb0208167227ed18dcbedc67af
Author: Christophe Fergeau <cfergeau redhat com>
Date: Thu Oct 23 21:13:29 2014 +0200
Return correct font from gtk_font_chooser_widget_find_font
Commit 30a1c4ab fixed several memleaks including one in
gtk_font_chooser_widget_find_font.
However, the fix causes one extra call to gtk_tree_model_iter_next()
after finding the font we look for (ie pango_font_description_equal
returns TRUE): the 'increment' part of the for loop
(gtk_tree_model_iter_next) is run before the 'exit condition' of the for
loop is evaluated.
This commit reverts this part of commit 30a1c4ab and adds an extra
call to pango_font_description_free in order to fix the leak.
https://bugzilla.gnome.org/show_bug.cgi?id=739111
gtk/gtkfontchooserwidget.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 71f23d9..66a3d45 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -882,18 +882,18 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget *fontchooser,
GtkTreeIter *iter)
{
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
- PangoFontDescription *desc;
- PangoFontFamily *family;
- gboolean valid, found;
+ gboolean valid;
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 && !found;
+ valid;
valid = gtk_tree_model_iter_next (priv->model, iter))
{
+ PangoFontDescription *desc;
+ PangoFontFamily *family;
+
gtk_tree_model_get (priv->model, iter,
FAMILY_COLUMN, &family,
-1);
@@ -905,13 +905,15 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget *fontchooser,
desc = tree_model_get_font_description (priv->model, iter);
pango_font_description_merge_static (desc, font_desc, FALSE);
- if (pango_font_description_equal (desc, font_desc))
- found = TRUE;
+ if (pango_font_description_equal (desc, font_desc)) {
+ pango_font_description_free (desc);
+ break;
+ }
pango_font_description_free (desc);
}
- return found;
+ return valid;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]