File xfce4-settings-fork-before-gtk-dbus-init.patch of Package xfce4-settings

From 73a60fcc1c2edf7fc835a715d0b9055afda8f971 Mon Sep 17 00:00:00 2001
From: Eric Koegel <eric.koegel@gmail.com>
Date: Mon, 28 Jul 2014 09:03:30 +0300
Subject: [PATCH] Fork before gtk/dbus init (Bug 11045)

https://mail.xfce.org/pipermail/xfce4-dev/2014-May/030715.html
has the rational for the change.
---
 xfsettingsd/main.c | 44 +++++++++++++++++++++++++++++++-------------
 1 file changed, 31 insertions(+), 13 deletions(-)

diff --git a/xfsettingsd/main.c b/xfsettingsd/main.c
index 55c4183..063d4a2 100644
--- a/xfsettingsd/main.c
+++ b/xfsettingsd/main.c
@@ -175,11 +175,12 @@ main (gint argc, gchar **argv)
 
     context = g_option_context_new (NULL);
     g_option_context_add_main_entries (context, option_entries, GETTEXT_PACKAGE);
-    g_option_context_add_group (context, gtk_get_option_group (FALSE));
+    /* We can't add the following command because it will invoke gtk_init
+       before we have a chance to fork.
+       g_option_context_add_group (context, gtk_get_option_group (FALSE));
+    */
     g_option_context_add_group (context, xfce_sm_client_get_option_group (argc, argv));
 
-    gtk_init (&argc, &argv);
-
     /* parse options */
     if (!g_option_context_parse (context, &argc, &argv, &error))
     {
@@ -207,6 +208,33 @@ main (gint argc, gchar **argv)
         return EXIT_SUCCESS;
     }
 
+    /* daemonize the process */
+    if (!opt_no_daemon)
+    {
+        if (daemonize () == -1)
+        {
+            /* show message and continue in normal mode */
+            g_warning ("Failed to fork the process: %s. Continuing in non-daemon mode.", g_strerror (errno));
+        }
+    }
+
+    if (!gtk_init_check (&argc, &argv))
+    {
+        if (G_LIKELY (error))
+        {
+            g_printerr ("%s: %s.\n", G_LOG_DOMAIN, error->message);
+            g_printerr (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
+            g_printerr ("\n");
+            g_error_free (error);
+        }
+        else
+        {
+            g_error ("Unable to open display.");
+        }
+
+        return EXIT_FAILURE;
+    }
+
     dbus_connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
     if (G_LIKELY (dbus_connection != NULL))
     {
@@ -254,16 +282,6 @@ main (gint argc, gchar **argv)
         g_clear_error (&error);
     }
 
-    /* daemonize the process */
-    if (!opt_no_daemon)
-    {
-        if (daemonize () == -1)
-        {
-            /* show message and continue in normal mode */
-            g_warning ("Failed to fork the process: %s. Continuing in non-daemon mode.", g_strerror (errno));
-        }
-    }
-
     /* launch settings manager */
     xsettings_helper = g_object_new (XFCE_TYPE_XSETTINGS_HELPER, NULL);
     xfce_xsettings_helper_register (XFCE_XSETTINGS_HELPER (xsettings_helper),
-- 
2.0.2

openSUSE Build Service is sponsored by