changeset 106560:e4fa191eaf50

Work around warning about g_set_prgname() called multiple times. * xterm.c (my_log_handler): New function. (x_term_init): Set my_log_handler as log handler during gtk_init so we can filter out buggy messages. (bug #5120).
author Jan Djärv <jan.h.d@swipnet.se>
date Sun, 13 Dec 2009 14:24:22 +0000
parents bac7488df503
children 85bf88fe0269
files src/ChangeLog src/xterm.c
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Dec 13 13:31:35 2009 +0000
+++ b/src/ChangeLog	Sun Dec 13 14:24:22 2009 +0000
@@ -1,5 +1,9 @@
 2009-12-13  Jan Djärv  <jan.h.d@swipnet.se>
 
+	* xterm.c (my_log_handler): New function.
+	(x_term_init): Set my_log_handler as log handler during gtk_init
+	so we can filter out buggy messages. (bug #5120).
+
 	* xterm.c (xg_scroll_callback): Parameter list changed,
 	use parameter GtkScrollType to determine scroll/line/page.
 	Only allow dragging if a button < 4 is grabbed (bug #5177).
--- a/src/xterm.c	Sun Dec 13 13:31:35 2009 +0000
+++ b/src/xterm.c	Sun Dec 13 14:24:22 2009 +0000
@@ -10020,6 +10020,19 @@
     return dpy_ok;
 }
 
+#ifdef USE_GTK
+static void
+my_log_handler (log_domain, log_level, message, user_data)
+     const gchar *log_domain;
+     GLogLevelFlags log_level;
+     const gchar *message;
+     gpointer user_data;
+{
+  if (!strstr (message, "g_set_prgname"))
+      fprintf (stderr, "%s-WARNING **: %s\n", log_domain, message);
+}
+#endif
+  
 /* Open a connection to X display DISPLAY_NAME, and return
    the structure that describes the open display.
    If we cannot contact the display, return null.  */
@@ -10054,7 +10067,7 @@
     char *argv[NUM_ARGV];
     char **argv2 = argv;
     GdkAtom atom;
-
+    guint id;
 #ifndef HAVE_GTK_MULTIDISPLAY
     if (!EQ (Vinitial_window_system, Qx))
       error ("Sorry, you cannot connect to X servers with the GTK toolkit");
@@ -10089,7 +10102,12 @@
 
         XSetLocaleModifiers ("");
 
+        /* Work around GLib bug that outputs a faulty warning. See
+           https://bugzilla.gnome.org/show_bug.cgi?id=563627.  */
+        id = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
+                                  | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
         gtk_init (&argc, &argv2);
+        g_log_remove_handler ("GLib", id);
 
         /* gtk_init does set_locale.  We must fix locale after calling it.  */
         fixup_locale ();