Fix a sporadic crash

This commit is contained in:
Matthias Clasen 2013-06-10 16:05:11 -04:00
parent 30a786eb76
commit bbe0140977
2 changed files with 141 additions and 1 deletions

View File

@ -0,0 +1,133 @@
From b26280702ad318e3a7fdc04c126a38e7c91729b5 Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Sat, 8 Jun 2013 14:10:41 -0400
Subject: [PATCH] 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 c5a5518..ff71eee 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-localeexec
OnlyShowIn=GNOME;
NoDisplay=true
X-GNOME-Autostart-Phase=Initialization
diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am
index 194a7cc..94b3861 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 0000000..1aca843
--- /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 24c1598..16017df 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 ();
--
1.8.2.1

View File

@ -1,6 +1,6 @@
Name: gnome-settings-daemon
Version: 3.8.3
Release: 1%{?dist}
Release: 2%{?dist}
Summary: The daemon sharing settings from GNOME to GTK+/KDE applications
Group: System Environment/Daemons
@ -12,6 +12,8 @@ Source: http://download.gnome.org/sources/%{name}/3.8/%{name}-%{version}
Patch0: %{name}-3.5.4-ppc-no-wacom.patch
# g-i-s takes this role now
Patch1: 0001-keyboard-Stop-adding-locale-based-input-sources-from.patch
# upstream fix
Patch2: 0001-Avoid-calling-setenv-after-starting-threads.patch
Requires: control-center-filesystem
Requires: colord
@ -80,6 +82,7 @@ The %{name}-updates package contains the updates plugin for %{name}
%patch0 -p1 -b .ppc-no-wacom
%endif
%patch1 -p1
%patch2 -p1
autoreconf -i -f
@ -206,6 +209,7 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_libdir}/gnome-settings-daemon-3.0/libgsd.so
%{_libexecdir}/gnome-settings-daemon
%{_libexecdir}/gnome-settings-daemon-localeexec
%{_libexecdir}/gsd-locate-pointer
%{_libexecdir}/gsd-printer
@ -255,6 +259,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.updates.gschema.xml
%changelog
* Mon Jun 10 2013 Matthias Clasen <mclasen@redhat.com> - 3.8.3-2
- Avoid calling setenv after threads are initialized (#919855)
* Fri Jun 7 2013 Rui Matos <rmatos@redhat.com> - 3.8.3-1
- Update to 3.8.3