GNOME Bugzilla – Bug 647908
gtkrc does not handle "shade()" in a locale safe manor
Last modified: 2011-04-27 21:11:27 UTC
When parsing gtkrc files, 'shade(0.5, "#color")' is not parsed in a locale neutral way. In locales where a ',' is used to separate floating point numbers instead of '.', parsing just fails on shade() directives. Attached is a minimal repro case, which produces the following output depending on the locale: --- $ gcc gtk_gdk_parsing.c `pkg-config --cflags --libs gtk+-2.0` $ LC_NUMERIC=C ./a.out Parsed color: #101010101010 $ LC_NUMERIC=ru_RU.utf8 ./a.out Gtk-Message: (for origin information, set GTK_DEBUG): failed to retrieve property `GtkWidget::link-color' of type `GdkColor' from rc file value "((GString*) 0x54c620)" of type `GString' (a.out:17856): Gdk-CRITICAL **: gdk_color_to_string: assertion `color != NULL' failed Parsed color: (null) --- This is a big problem for chromium as we read GdkColors for themeing purposes.
Created attachment 186050 [details] Test case
Created attachment 186052 [details] [review] gtkrc.c: Use g_ascii_dtostr for formatting floats
Review of attachment 186052 [details] [review]: Patching this in locally, I get a: (a.out:674): GLib-CRITICAL **: g_ascii_formatd: assertion `format[0] == '%'' failed when running the test case I supplied earlier. Removing the first space from the g_ascii_formatd format string and rebuilding made everything work, but then I assume that an extra "g_string_append(gstring, " ");" needs to be added for the space. Thanks for doing this, BTW.
Can I apply this patch to Gtk+ 2.24 (just copying it to debian/patches and debuild'ing)? I'm a reporter of the upstream bug.
Created attachment 186304 [details] [review] Locally tested and modified version of Colin's patch above. I tested and worked out the problem with the format string. I believe this fixes it.
Review of attachment 186304 [details] [review]: Hm, isn't your modified version here missing the space? (Thanks for fixing up my untested patch btw)
Created attachment 186443 [details] [review] Plus space in printf Good catch. Added the space to the printf format string.
Attachment 186052 [details] pushed as c4b2d3a - gtkrc.c: Use g_ascii_dtostr for formatting floats