[gtk+/font-chooser: 46/84] GtkFontChooser: Fix segmentation fault in deprecated size list population



commit 52f42913c7f43f569176002d2e3f73c8869b71b0
Author: Alberto Ruiz <aruiz gnome org>
Date:   Thu Apr 28 01:20:44 2011 +0100

    GtkFontChooser: Fix segmentation fault in deprecated size list population

 gtk/gtkfontchooser.c      |   20 +++++++++++++-------
 tests/testfontselection.c |    7 ++++---
 2 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkfontchooser.c b/gtk/gtkfontchooser.c
index 2fc0aa4..4fb70e8 100644
--- a/gtk/gtkfontchooser.c
+++ b/gtk/gtkfontchooser.c
@@ -442,7 +442,7 @@ set_range_marks (GtkFontSelectionPrivate *priv,
         {
           GtkTreeIter iter;
 
-          g_string_printf ("%d", sizes[i]);
+          g_string_printf (size_str, "%d", sizes[i]);
 
           gtk_scale_add_mark (GTK_SCALE (size_slider),
                               (gdouble) sizes[i],
@@ -471,7 +471,7 @@ cursor_changed_cb (GtkTreeView *treeview, gpointer data)
   GtkTreeIter iter;
   GtkTreePath *path = gtk_tree_path_new ();
   
-  GtkFontSelection        *fontsel = (GtkFontSelection*)data;
+  GtkFontSelection *fontsel = (GtkFontSelection*)data;
   
   gtk_tree_view_get_cursor (treeview, &path, NULL);
   
@@ -1032,8 +1032,10 @@ gtk_font_selection_get_family_list (GtkFontSelection *fontsel)
 {
   GtkFontSelectionPrivate *priv = fontsel->priv;
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  if (!priv->font_list)
+    initialize_deprecated_widgets (fontsel);
 
-  return NULL;
+  return priv->font_list;
 }
 
 /**
@@ -1052,8 +1054,10 @@ gtk_font_selection_get_face_list (GtkFontSelection *fontsel)
 {
   GtkFontSelectionPrivate *priv = fontsel->priv;
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  if (!priv->face_list)
+    initialize_deprecated_widgets (fontsel);
 
-  return NULL;
+  return priv->face_list;
 }
 
 /**
@@ -1091,8 +1095,10 @@ gtk_font_selection_get_size_list (GtkFontSelection *fontsel)
 {
   GtkFontSelectionPrivate *priv = fontsel->priv;
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  if (!priv->size_list)
+    initialize_deprecated_widgets (fontsel);
 
-  return NULL;
+  return priv->size_list;
 }
 
 /**
@@ -1132,7 +1138,7 @@ gtk_font_selection_get_family (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
 
-  return NULL;
+  return fontsel->priv->family;
 }
 
 /**
@@ -1153,7 +1159,7 @@ gtk_font_selection_get_face (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
 
-  return NULL;
+  return fontsel->priv->face;
 }
 
 /**
diff --git a/tests/testfontselection.c b/tests/testfontselection.c
index 0b721f5..42efdc1 100644
--- a/tests/testfontselection.c
+++ b/tests/testfontselection.c
@@ -35,13 +35,14 @@ main (int argc, char *argv[])
   dialog = gtk_font_selection_dialog_new (NULL);
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_widget_set_size_request (window, 300, 300);
   vbox = gtk_vbox_new (TRUE, 6);
   gtk_container_add (GTK_CONTAINER (window), vbox);
 
   fontsel = gtk_font_selection_dialog_get_font_selection (GTK_FONT_SELECTION_DIALOG (dialog));
-  gtk_container_add (GTK_CONTAINER (window), gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel)));
-  gtk_container_add (GTK_CONTAINER (window), gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel)));
-  gtk_container_add (GTK_CONTAINER (window), gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel)));
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel)));
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel)));
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel)));
 
   gtk_widget_show_all (window);
 



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