From 0160ed937d9074fd398b65a4bb792f17838b8eda Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 6 Sep 2016 11:20:39 +0100 Subject: [PATCH] document portal: cope with multiple events that would cause failure If the name is lost *and* the session bus is closed, we would crash with an assertion failure when the GError is overwritten. Signed-off-by: Simon McVittie --- document-portal/xdp-main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/document-portal/xdp-main.c b/document-portal/xdp-main.c index a3bacc0a..8c2c5e47 100644 --- a/document-portal/xdp-main.c +++ b/document-portal/xdp-main.c @@ -972,8 +972,13 @@ on_name_lost (GDBusConnection *connection, gpointer user_data) { g_debug ("%s lost", name); - final_exit_status = 20; - g_set_error (&exit_error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "D-Bus name \"%s\" lost", name); + + if (final_exit_status == 0) + final_exit_status = 20; + + if (exit_error == NULL) + g_set_error (&exit_error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "D-Bus name \"%s\" lost", name); + g_main_loop_quit (loop); } @@ -991,7 +996,9 @@ session_bus_closed (GDBusConnection *connection, gboolean remote_peer_vanished, GError *bus_error) { - g_set_error (&exit_error, G_IO_ERROR, G_IO_ERROR_BROKEN_PIPE, "Disconnected from session bus"); + if (exit_error == NULL) + g_set_error (&exit_error, G_IO_ERROR, G_IO_ERROR_BROKEN_PIPE, "Disconnected from session bus"); + g_main_loop_quit (loop); }