From 5cb44f6387de341ef254d33f76ec26e164a5ee0d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 8 Jun 2013 14:10:41 -0400 Subject: Avoid calling setenv after starting threads In particular, we can't get the locale value out of GSettings in order to set LC_PAPER etc, since calling into GSettings initializes the dconf backend which in turn uses gdbus, which starts a worker thread. As a simple workaround, set up the locale environment in a small wrapper script that then exec's the g-s-d binary. https://bugzilla.gnome.org/show_bug.cgi?id=701322 --- data/gnome-settings-daemon.desktop.in.in | 2 +- gnome-settings-daemon/Makefile.am | 9 ++++++ .../gnome-settings-daemon-localeexec.in | 19 +++++++++++++ gnome-settings-daemon/main.c | 33 ---------------------- 4 files changed, 29 insertions(+), 34 deletions(-) create mode 100755 gnome-settings-daemon/gnome-settings-daemon-localeexec.in diff --git a/data/gnome-settings-daemon.desktop.in.in b/data/gnome-settings-daemon.desktop.in.in index c5a5518c..b098f0f8 100644 --- a/data/gnome-settings-daemon.desktop.in.in +++ b/data/gnome-settings-daemon.desktop.in.in @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application _Name=GNOME Settings Daemon -Exec=@libexecdir@/gnome-settings-daemon +Exec=@libexecdir@/gnome-settings-daemon.sh OnlyShowIn=GNOME; NoDisplay=true X-GNOME-Autostart-Phase=Initialization diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am index 194a7cc7..94b38612 100644 --- a/gnome-settings-daemon/Makefile.am +++ b/gnome-settings-daemon/Makefile.am @@ -48,6 +48,15 @@ gsddir = $(libexecdir) gsd_PROGRAMS = \ gnome-settings-daemon +gsd_SCRIPTS = \ + gnome-settings-daemon-localeexec + +EXTRA_DIST = \ + gnome-settings-daemon-localeexec.in + +gnome-settings-daemon-localeexec: gnome-settings-daemon-localeexec.in + $(AM_V_GEN) sed -e "s|\@libexecdir\@|$(libexecdir)|" -e "s|\@prefix\@|$(prefix)|" $< > $@.tmp && mv $@.tmp $@ + apidir = $(includedir)/gnome-settings-daemon-$(GSD_API_VERSION)/gnome-settings-daemon api_DATA = \ gnome-settings-plugin.h diff --git a/gnome-settings-daemon/gnome-settings-daemon-localeexec.in b/gnome-settings-daemon/gnome-settings-daemon-localeexec.in new file mode 100755 index 00000000..1aca8439 --- /dev/null +++ b/gnome-settings-daemon/gnome-settings-daemon-localeexec.in @@ -0,0 +1,19 @@ +#! /bin/bash + +SETTING=$(gsettings get org.gnome.system.locale region) +REGION=${SETTING//\,/} + +if [ -n "$REGION" ]; then + export LC_TIME=$REGION + export LC_NUMERIC=$REGION + export LC_MONETARY=$REGION + export LC_MEASUREMENT=$REGION + export LC_PAPER=$REGION +fi + +if [ -x @prefix@/bin/ibus-daemon ]; then + export QT_IM_MODULE=ibus + export XMODIFIERS=@im=ibus +fi + +exec @libexecdir@/gnome-settings-daemon diff --git a/gnome-settings-daemon/main.c b/gnome-settings-daemon/main.c index 24c15988..16017df8 100644 --- a/gnome-settings-daemon/main.c +++ b/gnome-settings-daemon/main.c @@ -279,37 +279,6 @@ set_legacy_ibus_env_vars (GDBusProxy *proxy) } #endif -/* Keep synchronised with set_locale() and - * set_legacy_ibus_env_vars() above */ -static void -set_locale_env (void) -{ - GSettings *locale_settings; - gchar *region; - - /* Set locale environment */ - locale_settings = g_settings_new ("org.gnome.system.locale"); - region = g_settings_get_string (locale_settings, "region"); - if (region[0]) { - g_setenv ("LC_TIME", region, TRUE); - g_setenv ("LC_NUMERIC", region, TRUE); - g_setenv ("LC_MONETARY", region, TRUE); - g_setenv ("LC_MEASUREMENT", region, TRUE); - g_setenv ("LC_PAPER", region, TRUE); - } - g_free (region); - g_object_unref (locale_settings); - -#ifdef HAVE_IBUS - /* Set IBus legacy environment */ - if (is_program_in_path ("ibus-daemon") && - keyboard_plugin_is_enabled ()) { - g_setenv ("QT_IM_MODULE", "ibus", TRUE); - g_setenv ("XMODIFIERS", "@im=ibus", TRUE); - } -#endif -} - static void register_with_gnome_session (GDBusProxy *proxy) { @@ -499,8 +468,6 @@ main (int argc, char *argv[]) g_log_set_default_handler (gsd_log_default_handler, NULL); - set_locale_env (); - notify_init ("gnome-settings-daemon"); bus_register (); -- cgit v1.2.1