From ec58cbbc612992e2de70cbbb858bbbb25cac6aff Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 30 May 2017 12:46:19 -0400 Subject: [PATCH] fail-whale: handle X server dying before startup This commit deals with gtk_init_with_args failing, without setting an error (which it does if it can't connect to the X server). --- gnome-session/gsm-fail-whale-dialog.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gnome-session/gsm-fail-whale-dialog.c b/gnome-session/gsm-fail-whale-dialog.c index f53ce417..c5889efc 100644 --- a/gnome-session/gsm-fail-whale-dialog.c +++ b/gnome-session/gsm-fail-whale-dialog.c @@ -344,55 +344,62 @@ setup_window (GsmFailWhaleDialog *fail_dialog) G_CALLBACK (on_logout_clicked), fail_dialog); } } static void gsm_fail_whale_dialog_init (GsmFailWhaleDialog *fail_dialog) { fail_dialog->priv = GSM_FAIL_WHALE_DIALOG_GET_PRIVATE (fail_dialog); } static gboolean debug_mode = FALSE; static gboolean allow_logout = FALSE; static gboolean extensions = FALSE; int main (int argc, char *argv[]) { GOptionEntry entries[] = { { "debug", 0, 0, G_OPTION_ARG_NONE, &debug_mode, N_("Enable debugging code"), NULL }, { "allow-logout", 0, 0, G_OPTION_ARG_NONE, &allow_logout, N_("Allow logout"), NULL }, { "extensions", 0, 0, G_OPTION_ARG_NONE, &extensions, N_("Show extension warning"), NULL }, { NULL, 0, 0, 0, NULL, NULL, NULL } }; GsmFailWhaleDialog *fail_dialog; GError *error = NULL; bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); - gtk_init_with_args (&argc, &argv, " - fail whale", - entries, GETTEXT_PACKAGE, - &error); - if (error != NULL) { - g_warning ("%s", error->message); - exit (1); - } + if (!gtk_init_with_args (&argc, &argv, " - fail whale", + entries, GETTEXT_PACKAGE, + &error)) { + if (error != NULL) { + g_warning ("%s", error->message); + exit (1); + } + + /* display server probably went away. Could be for legitimate reasons, could be for + * unexpected reasons. If it went away unexpectantly, that's logged elsewhere, so + * let's not add noise by logging here. + */ + return 0; + } fail_dialog = g_object_new (GSM_TYPE_FAIL_WHALE_DIALOG, NULL); fail_dialog->priv->debug_mode = debug_mode; fail_dialog->priv->allow_logout = allow_logout; fail_dialog->priv->extensions = extensions; setup_window (fail_dialog); g_signal_connect (fail_dialog, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (GTK_WIDGET (fail_dialog)); gtk_main (); return 0; } -- 2.13.0