summaryrefslogtreecommitdiffstats
path: root/src/widgets/font-selector.cpp
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2008-01-30 08:51:08 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2008-01-30 08:51:08 +0000
commitf0065dcd2f13f51ab5edcab9d8269fa59580e922 (patch)
tree86dd8919a6b476091c46b6fd1d5eaaa34340f718 /src/widgets/font-selector.cpp
parentrename grid arrange to rows and columns (diff)
downloadinkscape-f0065dcd2f13f51ab5edcab9d8269fa59580e922.tar.gz
inkscape-f0065dcd2f13f51ab5edcab9d8269fa59580e922.zip
fix 169057 and prevent non-numeric input for font size
(bzr r4618)
Diffstat (limited to 'src/widgets/font-selector.cpp')
-rw-r--r--src/widgets/font-selector.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index 9da48d0e6..6745fcc59 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -309,17 +309,30 @@ static void sp_font_selector_style_select_row (GtkTreeSelection *selection,
static void sp_font_selector_size_changed( GtkComboBox */*cbox*/, SPFontSelector *fsel )
{
- char *sstr = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size));
+ char *text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size));
gfloat old_size = fsel->fontsize;
- fsel->fontsize = MAX(atof(sstr), 0.1);
+
+ gchar *endptr;
+ gdouble value = -1;
+ if (text) {
+ value = g_strtod (text, &endptr);
+ if (endptr == text) // conversion failed, non-numeric input
+ value = -1;
+ free (text);
+ }
+ if (value <= 0) {
+ return; // could not parse value
+ }
+ if (value > 10000)
+ value = 10000; // somewhat arbitrary, but text&font preview freezes with too huge fontsizes
+
+ fsel->fontsize = value;
if ( fabs(fsel->fontsize-old_size) > 0.001)
{
fsel->fontsize_dirty = true;
}
sp_font_selector_emit_set (fsel);
-
- free (sstr);
}
static void sp_font_selector_emit_set (SPFontSelector *fsel)