[gtk+/gtk-3-22] main: Set the error if gtk_init_with_args fails



commit 65b18a4fc1605e2a142895c2e995b50a4964adbd
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jul 21 17:48:53 2017 +0200

    main: Set the error if gtk_init_with_args fails
    
    This fixes a fallout from 8a7d0ab481345708 where the error wasn't being
    set when a display couldn't be opened right after parsing the
    commandline.
    
    It also fixes an older bug where the error would be left unset if the
    commandline had already been parsed before (ie. when gtk_initialized
    is TRUE).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771959

 gtk/gtkmain.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 0850324..af854ce 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -992,15 +992,22 @@ gtk_init_with_args (gint                 *argc,
     return FALSE;
 
 done:
-  if (GDK_PRIVATE_CALL (gdk_display_open_default) () != NULL)
+  if (GDK_PRIVATE_CALL (gdk_display_open_default) () == NULL)
     {
-      if (gtk_get_debug_flags () & GTK_DEBUG_INTERACTIVE)
-        gtk_window_set_interactive_debugging (TRUE);
+      const char *display_name = gdk_get_display_arg_name ();
+      g_set_error (error,
+                   G_OPTION_ERROR,
+                   G_OPTION_ERROR_FAILED,
+                   _("Cannot open display: %s"),
+                   display_name ? display_name : "" );
 
-      return TRUE;
+      return FALSE;
     }
 
-  return FALSE;
+  if (gtk_get_debug_flags () & GTK_DEBUG_INTERACTIVE)
+    gtk_window_set_interactive_debugging (TRUE);
+
+  return TRUE;
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]