[gtk+] Make gtk_init_check work as expected



commit 65cd2a59c3c8e46e6baa7a6f0cb73dae22f2fd37
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Mar 23 19:41:39 2013 -0400

    Make gtk_init_check work as expected
    
    When no GDK backend can be initialized (either because
    GDK_BACKEND has been set to the wrong value, or the backends
    are simply not included), the expectation is that gtk_init_check
    should return FALSE, not error out.
    This commit makes it so, by using gdk_display_manager_peek
    instead of gdk_display_manager_get in code paths that are used
    during initialization.

 gtk/gtkmodules.c |   42 +++++++++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtkmodules.c b/gtk/gtkmodules.c
index 5a15925..ecbe88f 100644
--- a/gtk/gtkmodules.c
+++ b/gtk/gtkmodules.c
@@ -517,8 +517,8 @@ display_opened_cb (GdkDisplayManager *display_manager,
 }
 
 void
-_gtk_modules_init (gint        *argc, 
-                  gchar     ***argv, 
+_gtk_modules_init (gint        *argc,
+                  gchar     ***argv,
                   const gchar *gtk_modules_args)
 {
   GdkDisplayManager *display_manager;
@@ -526,7 +526,7 @@ _gtk_modules_init (gint        *argc,
 
   g_assert (gtk_argv == NULL);
 
-  if (argc && argv) 
+  if (argc && argv)
     {
       /* store argc and argv for later use in mod initialization */
       gtk_argc = *argc;
@@ -536,22 +536,26 @@ _gtk_modules_init (gint        *argc,
       gtk_argv [*argc] = NULL;
     }
 
-  display_manager = gdk_display_manager_get ();
-  default_display_opened = gdk_display_get_default () != NULL;
-  g_signal_connect (display_manager, "notify::default-display",
-                   G_CALLBACK (default_display_notify_cb), 
-                   NULL);
-  g_signal_connect (display_manager, "display-opened",
-                   G_CALLBACK (display_opened_cb), 
-                   NULL);
-
-  if (gtk_modules_args) {
-    /* Modules specified in the GTK_MODULES environment variable
-     * or on the command line are always loaded, so we'll just leak 
-     * the refcounts.
-     */
-    g_slist_free (load_modules (gtk_modules_args));
-  }
+  display_manager = gdk_display_manager_peek ();
+  if (display_manager != NULL)
+    {
+      default_display_opened = gdk_display_get_default () != NULL;
+      g_signal_connect (display_manager, "notify::default-display",
+                        G_CALLBACK (default_display_notify_cb),
+                        NULL);
+      g_signal_connect (display_manager, "display-opened",
+                        G_CALLBACK (display_opened_cb),
+                        NULL);
+    }
+
+  if (gtk_modules_args)
+    {
+      /* Modules specified in the GTK_MODULES environment variable
+       * or on the command line are always loaded, so we'll just leak
+       * the refcounts.
+       */
+      g_slist_free (load_modules (gtk_modules_args));
+    }
 }
 
 static void


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