Blame SOURCES/0001-Revert-Revert-plugins-Work-around-startup-deadlock.patch

c8e532
From 3b383ffcb65dcd318cdb9c1bf3e039007e628ec3 Mon Sep 17 00:00:00 2001
c8e532
From: Rui Matos <tiagomatos@gmail.com>
c8e532
Date: Wed, 11 Oct 2017 18:08:52 +0200
c8e532
Subject: [PATCH 1/3] Revert "Revert "plugins: Work-around startup deadlock""
c8e532
c8e532
This reverts commit e0f230ce6124fac47bc0810d30ff78ec327152ca.
c8e532
---
c8e532
 plugins/common/daemon-skeleton-gtk.h | 4 ++++
c8e532
 plugins/common/daemon-skeleton.h     | 4 ++++
c8e532
 2 files changed, 8 insertions(+)
c8e532
c8e532
diff --git a/plugins/common/daemon-skeleton-gtk.h b/plugins/common/daemon-skeleton-gtk.h
c8e532
index 2194b3d6..500ff3de 100644
c8e532
--- a/plugins/common/daemon-skeleton-gtk.h
c8e532
+++ b/plugins/common/daemon-skeleton-gtk.h
c8e532
@@ -172,60 +172,64 @@ set_empty_gtk_theme (gboolean set)
c8e532
 		/* Override GTK_THEME to reduce overhead of CSS engine. By using
c8e532
 		 * GTK_THEME environment variable, GtkSettings is not allowed to
c8e532
 		 * initially parse the Adwaita theme.
c8e532
 		 *
c8e532
 		 * https://bugzilla.gnome.org/show_bug.cgi?id=780555 */
c8e532
 		old_gtk_theme = g_strdup (g_getenv ("GTK_THEME"));
c8e532
 		g_setenv ("GTK_THEME", "Disabled", TRUE);
c8e532
 	} else {
c8e532
 		/* GtkSettings has loaded, so we can drop GTK_THEME used to initialize
c8e532
 		 * our internal theme. Only the main thread accesses the GTK_THEME
c8e532
 		 * environment variable, so this is safe to release. */
c8e532
 		if (old_gtk_theme != NULL)
c8e532
 			g_setenv ("GTK_THEME", old_gtk_theme, TRUE);
c8e532
 		else
c8e532
 			g_unsetenv ("GTK_THEME");
c8e532
 	}
c8e532
 }
c8e532
 
c8e532
 int
c8e532
 main (int argc, char **argv)
c8e532
 {
c8e532
         GError  *error;
c8e532
 
c8e532
         bindtextdomain (GETTEXT_PACKAGE, GNOME_SETTINGS_LOCALEDIR);
c8e532
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
c8e532
         textdomain (GETTEXT_PACKAGE);
c8e532
         setlocale (LC_ALL, "");
c8e532
 
c8e532
         set_empty_gtk_theme (TRUE);
c8e532
 
c8e532
+        /* Work around https://bugzilla.gnome.org/show_bug.cgi?id=674885 */
c8e532
+        g_type_ensure (G_TYPE_DBUS_CONNECTION);
c8e532
+        g_type_ensure (G_TYPE_DBUS_PROXY);
c8e532
+
c8e532
         gdk_set_allowed_backends ("x11");
c8e532
 
c8e532
         error = NULL;
c8e532
         if (! gtk_init_with_args (&argc, &argv, PLUGIN_NAME, entries, NULL, &error)) {
c8e532
                 if (error != NULL) {
c8e532
                         fprintf (stderr, "%s\n", error->message);
c8e532
                         g_error_free (error);
c8e532
                 }
c8e532
                 exit (1);
c8e532
         }
c8e532
 
c8e532
         set_empty_gtk_theme (FALSE);
c8e532
 
c8e532
         if (verbose) {
c8e532
                 g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
c8e532
                 /* Work around GLib not flushing the output for us by explicitly
c8e532
                  * setting buffering to a sane behaviour. This is important
c8e532
                  * during testing when the output is not going to a TTY and
c8e532
                  * we are reading messages from g_debug on stdout.
c8e532
                  *
c8e532
                  * See also
c8e532
                  *  https://bugzilla.gnome.org/show_bug.cgi?id=792432
c8e532
                  */
c8e532
                 setlinebuf (stdout);
c8e532
         }
c8e532
 
c8e532
 	if (timeout > 0) {
c8e532
 		guint id;
c8e532
 		id = g_timeout_add_seconds (timeout, (GSourceFunc) gtk_main_quit, NULL);
c8e532
 		g_source_set_name_by_id (id, "[gnome-settings-daemon] gtk_main_quit");
c8e532
diff --git a/plugins/common/daemon-skeleton.h b/plugins/common/daemon-skeleton.h
c8e532
index 367ac1ec..83493ca1 100644
c8e532
--- a/plugins/common/daemon-skeleton.h
c8e532
+++ b/plugins/common/daemon-skeleton.h
c8e532
@@ -147,60 +147,64 @@ on_client_registered (GObject             *source_object,
c8e532
 static void
c8e532
 register_with_gnome_session (GMainLoop *loop)
c8e532
 {
c8e532
 	GDBusProxy *proxy;
c8e532
 	const char *startup_id;
c8e532
 
c8e532
 	proxy = G_DBUS_PROXY (gnome_settings_bus_get_session_proxy ());
c8e532
 	startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
c8e532
 	g_dbus_proxy_call (proxy,
c8e532
 			   "RegisterClient",
c8e532
 			   g_variant_new ("(ss)", dummy_name ? dummy_name : PLUGIN_NAME, startup_id ? startup_id : ""),
c8e532
 			   G_DBUS_CALL_FLAGS_NONE,
c8e532
 			   -1,
c8e532
 			   NULL,
c8e532
 			   (GAsyncReadyCallback) on_client_registered,
c8e532
 			   loop);
c8e532
 }
c8e532
 
c8e532
 int
c8e532
 main (int argc, char **argv)
c8e532
 {
c8e532
         GError *error = NULL;
c8e532
         GOptionContext *context;
c8e532
         GMainLoop *loop;
c8e532
 
c8e532
         bindtextdomain (GETTEXT_PACKAGE, GNOME_SETTINGS_LOCALEDIR);
c8e532
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
c8e532
         textdomain (GETTEXT_PACKAGE);
c8e532
         setlocale (LC_ALL, "");
c8e532
 
c8e532
+        /* Work around https://bugzilla.gnome.org/show_bug.cgi?id=674885 */
c8e532
+        g_type_ensure (G_TYPE_DBUS_CONNECTION);
c8e532
+        g_type_ensure (G_TYPE_DBUS_PROXY);
c8e532
+
c8e532
         context = g_option_context_new (NULL);
c8e532
         g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
c8e532
         if (!g_option_context_parse (context, &argc, &argv, &error)) {
c8e532
                 fprintf (stderr, "%s\n", error->message);
c8e532
                 g_error_free (error);
c8e532
                 exit (1);
c8e532
         }
c8e532
         g_option_context_free (context);
c8e532
 
c8e532
 	loop = g_main_loop_new (NULL, FALSE);
c8e532
 
c8e532
         if (verbose) {
c8e532
                 g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
c8e532
                 /* Work around GLib not flushing the output for us by explicitly
c8e532
                  * setting buffering to a sane behaviour. This is important
c8e532
                  * during testing when the output is not going to a TTY and
c8e532
                  * we are reading messages from g_debug on stdout.
c8e532
                  *
c8e532
                  * See also
c8e532
                  *  https://bugzilla.gnome.org/show_bug.cgi?id=792432
c8e532
                  */
c8e532
                 setlinebuf (stdout);
c8e532
         }
c8e532
 
c8e532
 	if (timeout > 0) {
c8e532
 		guint id;
c8e532
 		id = g_timeout_add_seconds (timeout, (GSourceFunc) g_main_loop_quit, loop);
c8e532
 		g_source_set_name_by_id (id, "[gnome-settings-daemon] g_main_loop_quit");
c8e532
 	}
c8e532
 
c8e532
-- 
c8e532
2.17.0
c8e532