From: buliabyak Date: Wed, 30 Jan 2008 08:51:08 +0000 (+0000) Subject: fix 169057 and prevent non-numeric input for font size X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cf937df2f59e2ed7349424a7c238dbcd7b7d5805;p=inkscape.git fix 169057 and prevent non-numeric input for font size --- 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)