[Xfce4-commits] [xfce/xfce4-session] 02/02: Fix the shutdown/reboot in xfsm-manager
noreply at xfce.org
noreply at xfce.org
Sat May 21 07:19:27 CEST 2016
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository xfce/xfce4-session.
commit 95617f7759eb99eda65defe9f65944062a494a91
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Sat May 21 08:16:51 2016 +0300
Fix the shutdown/reboot in xfsm-manager
With the new GDBUS setup, we can't just call gtk_main_quit to exit
since we'll never run the name_lost function which actually calls
shutdown/reboot. This patch changes the gtk_main_quit calls to be
a manager-quit signal which the main.c source will watch and
react to.
---
xfce4-session/main.c | 47 ++++++++++++++++++++++++++++++-----------
xfce4-session/xfsm-consolekit.c | 4 ++++
xfce4-session/xfsm-manager.c | 33 ++++++++++++++++++++++++++---
xfce4-session/xfsm-shutdown.c | 2 +-
4 files changed, 70 insertions(+), 16 deletions(-)
diff --git a/xfce4-session/main.c b/xfce4-session/main.c
index 73aba71..b2a01d5 100644
--- a/xfce4-session/main.c
+++ b/xfce4-session/main.c
@@ -71,6 +71,7 @@ static gboolean opt_disable_tcp = FALSE;
static gboolean opt_version = FALSE;
static XfsmManager *manager = NULL;
static XfconfChannel *channel = NULL;
+static guint name_id = 0;
static GOptionEntry option_entries[] =
{
@@ -79,6 +80,12 @@ static GOptionEntry option_entries[] =
{ NULL }
};
+
+static void name_lost (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data);
+
+
static void
setup_environment (void)
{
@@ -148,13 +155,25 @@ init_display (XfsmManager *manager,
static void
+manager_quit_cb (XfsmManager *manager, gpointer user_data)
+{
+ GDBusConnection *connection = G_DBUS_CONNECTION (user_data);
+
+ g_bus_unown_name (name_id);
+
+ name_lost (connection, "xfce4-session", manager);
+}
+
+
+
+static void
bus_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
GdkDisplay *dpy;
- g_debug ("bus_acquired %s\n", name);
+ xfsm_verbose ("bus_acquired %s\n", name);
manager = xfsm_manager_new (connection);
@@ -162,6 +181,11 @@ bus_acquired (GDBusConnection *connection,
g_critical ("Could not create XfsmManager");
}
+ g_signal_connect(G_OBJECT(manager),
+ "manager-quit",
+ G_CALLBACK(manager_quit_cb),
+ connection);
+
setup_environment ();
channel = xfsm_open_config ();
@@ -190,7 +214,7 @@ name_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
- g_debug ("name_acquired\n");
+ xfsm_verbose ("name_acquired\n");
}
@@ -205,10 +229,10 @@ name_lost (GDBusConnection *connection,
XfsmShutdown *shutdown_helper;
gboolean succeed = TRUE;
- g_debug ("name_lost\n");
+ xfsm_verbose ("name_lost\n");
/* Release the object */
- g_debug ("Disconnected from D-Bus");
+ xfsm_verbose ("Disconnected from D-Bus");
shutdown_type = xfsm_manager_get_shutdown_type (manager);
@@ -229,6 +253,7 @@ name_lost (GDBusConnection *connection,
}
g_object_unref (shutdown_helper);
+ g_clear_error (&error);
gtk_main_quit ();
}
@@ -238,15 +263,13 @@ name_lost (GDBusConnection *connection,
static void
xfsm_dbus_init (void)
{
- int ret;
-
- ret = g_bus_own_name (G_BUS_TYPE_SESSION,
- "org.xfce.SessionManager",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- bus_acquired, name_acquired, name_lost,
- NULL, NULL);
+ name_id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ "org.xfce.SessionManager",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ bus_acquired, name_acquired, name_lost,
+ NULL, NULL);
- if (ret == 0)
+ if (name_id == 0)
{
g_printerr ("%s: Another session manager is already running\n", PACKAGE_NAME);
exit (EXIT_FAILURE);
diff --git a/xfce4-session/xfsm-consolekit.c b/xfce4-session/xfsm-consolekit.c
index 3e90ed8..d1dd73a 100644
--- a/xfce4-session/xfsm-consolekit.c
+++ b/xfce4-session/xfsm-consolekit.c
@@ -258,6 +258,8 @@ xfsm_consolekit_try_method (XfsmConsolekit *consolekit,
return FALSE;
}
+ xfsm_verbose ("calling %s\n", method);
+
variant = g_dbus_proxy_call_sync (consolekit->proxy,
method,
g_variant_new ("()"),
@@ -288,6 +290,8 @@ xfsm_consolekit_try_sleep (XfsmConsolekit *consolekit,
return FALSE;
}
+ xfsm_verbose ("calling %s\n", method);
+
variant = g_dbus_proxy_call_sync (consolekit->proxy,
method,
g_variant_new_boolean (TRUE),
diff --git a/xfce4-session/xfsm-manager.c b/xfce4-session/xfsm-manager.c
index e559b97..e6832d5 100644
--- a/xfce4-session/xfsm-manager.c
+++ b/xfce4-session/xfsm-manager.c
@@ -127,6 +127,9 @@ struct _XfsmManager
typedef struct _XfsmManagerClass
{
XfsmDbusManagerSkeletonClass parent;
+
+ /*< signals >*/
+ void (*quit)(XfsmManager *manager);
} XfsmManagerClass;
typedef struct
@@ -143,6 +146,13 @@ typedef struct
gboolean allow_save;
} ShutdownIdleData;
+enum
+{
+ MANAGER_QUIT,
+ LAST_SIGNAL,
+};
+
+static guint manager_signals[LAST_SIGNAL] = { 0, };
static void xfsm_manager_finalize (GObject *obj);
@@ -173,6 +183,14 @@ xfsm_manager_class_init (XfsmManagerClass *klass)
gobject_class->finalize = xfsm_manager_finalize;
+ manager_signals[MANAGER_QUIT] = g_signal_new("manager-quit",
+ G_OBJECT_CLASS_TYPE(gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(XfsmManagerClass, quit),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
xfsm_manager_dbus_class_init (klass);
}
@@ -1117,6 +1135,7 @@ xfsm_manager_save_yourself_global (XfsmManager *manager,
manager->shutdown_type,
&error))
{
+ xfsm_verbose ("failed calling shutdown, error message was %s", error->message);
xfce_message_dialog (NULL, _("Shutdown Failed"),
"dialog-error",
manager->shutdown_type == XFSM_SHUTDOWN_SUSPEND
@@ -1330,7 +1349,7 @@ xfsm_manager_close_connection (XfsmManager *manager,
g_source_remove (manager->die_timeout_id);
manager->die_timeout_id = 0;
}
- gtk_main_quit ();
+ g_signal_emit(G_OBJECT(manager), manager_signals[MANAGER_QUIT], 0);
}
else if (manager->state == XFSM_MANAGER_SHUTDOWN || manager->state == XFSM_MANAGER_CHECKPOINT)
{
@@ -1412,12 +1431,20 @@ xfsm_manager_terminate_client (XfsmManager *manager,
}
+static gboolean
+manager_quit_signal (XfsmManager *manager)
+{
+ g_signal_emit(G_OBJECT(manager), manager_signals[MANAGER_QUIT], 0);
+ return FALSE;
+}
+
+
void
xfsm_manager_perform_shutdown (XfsmManager *manager)
{
GList *lp;
- xfsm_verbose ("entering");
+ xfsm_verbose ("entering\n");
/* send SmDie message to all clients */
xfsm_manager_set_state (manager, XFSM_MANAGER_SHUTDOWNPHASE2);
@@ -1461,7 +1488,7 @@ xfsm_manager_perform_shutdown (XfsmManager *manager)
/* give all clients the chance to close the connection */
manager->die_timeout_id = g_timeout_add (DIE_TIMEOUT,
- (GSourceFunc) gtk_main_quit,
+ (GSourceFunc) manager_quit_signal,
NULL);
}
diff --git a/xfce4-session/xfsm-shutdown.c b/xfce4-session/xfsm-shutdown.c
index 07ac338..e015323 100644
--- a/xfce4-session/xfsm-shutdown.c
+++ b/xfce4-session/xfsm-shutdown.c
@@ -238,7 +238,7 @@ xfsm_shutdown_try_restart (XfsmShutdown *shutdown,
}
else if (shutdown->consolekit != NULL)
{
- if (xfsm_consolekit_try_restart (shutdown->consolekit, NULL))
+ if (xfsm_consolekit_try_restart (shutdown->consolekit, error))
{
return TRUE;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list