From 7db6bf8f42a435afab9dd55f84c5304e74a88377 Mon Sep 17 00:00:00 2001
From: Alexander Schwinn <acs82@gmx.de>
Date: Mon, 21 Aug 2017 22:43:28 +0200
Subject: [PATCH] Followup of fix "8 second delay on logout" (Bug #13726)

---
 thunar/thunar-application.c    | 34 +++++++++++++++++-----------------
 thunar/thunar-application.h    |  2 ++
 thunar/thunar-session-client.c |  4 ++--
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index 6ea57239a..afd9e6c06 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -38,7 +38,6 @@
 #endif
 
 #include <stdlib.h>
-#include <glib-unix.h>
 
 #ifdef HAVE_GUDEV
 #include <gudev/gudev.h>
@@ -126,7 +125,6 @@ static void           thunar_application_dbus_init              (ThunarApplicati
 static void           thunar_application_startup                (GApplication           *application);
 static void           thunar_application_shutdown               (GApplication           *application);
 static void           thunar_application_activate               (GApplication           *application);
-static gboolean       thunar_application_handle_hangup_signal   (gpointer                user_data);
 static int            thunar_application_handle_local_options   (GApplication           *application,
                                                                  GVariantDict           *options);
 static int            thunar_application_command_line           (GApplication           *application,
@@ -282,11 +280,6 @@ thunar_application_init (ThunarApplication *application)
   application->progress_dialog = NULL;
   application->preferences     = NULL;
 
-#ifndef G_OS_WIN32
-  /* required in order to have no 8 second-delay on session-logout in daemon-mode */
-  g_unix_signal_add (SIGHUP, thunar_application_handle_hangup_signal, application);
-#endif
-
   g_application_set_flags (G_APPLICATION (application), G_APPLICATION_HANDLES_COMMAND_LINE);
   g_application_add_main_option_entries (G_APPLICATION (application), option_entries);
 }
@@ -463,16 +456,6 @@ thunar_application_finalize (GObject *object)
 
 
 
-static gboolean
-thunar_application_handle_hangup_signal (gpointer user_data)
-{
-  ThunarApplication *application = THUNAR_APPLICATION (user_data);
-  thunar_application_set_daemon (application, FALSE);
-  return FALSE;
-}
-
-
-
 static int
 thunar_application_handle_local_options (GApplication *gapp,
                                          GVariantDict *options)
@@ -1083,6 +1066,23 @@ thunar_application_get (void)
 
 
 
+/**
+ * thunar_application_quit:
+ * @application : a #ThunarApplication.
+ *
+ * Attempts to exit daemon mode(required if application is on hold) and leaves the gtk main loop
+ **/
+void
+thunar_application_quit (ThunarApplication *application)
+{
+  _thunar_return_if_fail (THUNAR_IS_APPLICATION (application));
+
+  thunar_application_set_daemon(application, FALSE);
+  gtk_main_quit ();
+}
+
+
+
 /**
  * thunar_application_get_daemon:
  * @application : a #ThunarApplication.
diff --git a/thunar/thunar-application.h b/thunar/thunar-application.h
index e1c6dda30..b28263035 100644
--- a/thunar/thunar-application.h
+++ b/thunar/thunar-application.h
@@ -42,6 +42,8 @@ GType                 thunar_application_get_type                   (void) G_GNU
 
 ThunarApplication    *thunar_application_get                        (void);
 
+void                  thunar_application_quit                       (ThunarApplication *application);
+
 gboolean              thunar_application_get_daemon                 (ThunarApplication *application);
 void                  thunar_application_set_daemon                 (ThunarApplication *application,
                                                                      gboolean           daemon);
diff --git a/thunar/thunar-session-client.c b/thunar/thunar-session-client.c
index 0347f148e..10177892a 100644
--- a/thunar/thunar-session-client.c
+++ b/thunar/thunar-session-client.c
@@ -338,8 +338,8 @@ thunar_session_client_die (SmcConn              connection,
   _thunar_return_if_fail (THUNAR_IS_SESSION_CLIENT (session_client));
   _thunar_return_if_fail (session_client->connection == connection);
 
-  /* terminate the application */
-  gtk_main_quit ();
+  ThunarApplication* application = thunar_application_get ();
+  thunar_application_quit (application);
 }
 
 
-- 
GitLab