Bug#283076: libgtk2.0-0: "cannot open display" message misleading

Mike Hommey Mike Hommey <mh@glandium.org>, 283076@bugs.debian.org
Fri, 26 Nov 2004 18:37:22 +0900


This is a multi-part MIME message sent by reportbug.

--===============0181312972==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Package: libgtk2.0-0
Version: 2.4.13-1.1
Severity: minor
Tags: patch

When running a gtk+2 application while it is impossible to open the
display for any reason, the error message can be misleading:

running DISPLAY=:1 gnome-cd prints:
(gnome-cd:8301): Gtk-WARNING **: cannot open display:

running gnome-cd --display=:1 prints:
(gnome-cd:8302): Gtk-WARNING **: cannot open display: :1

It can be misleading about the fact whether the DISPLAY variable is
correctly set or not.

The attached patch displays the content of the DISPLAY environment
variable when the --display argument has not been specified.

Mike

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.9-1-686
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)

Versions of packages libgtk2.0-0 depends on:
ii  libatk1.0-0               1.8.0-3        The ATK accessibility toolkit
ii  libc6                     2.3.2.ds1-18   GNU C Library: Shared libraries an
ii  libfontconfig1            2.2.3-4        generic font configuration library
ii  libfreetype6              2.1.7-2.3      FreeType 2 font engine, shared lib
ii  libglib2.0-0              2.4.7-1        The GLib library of C routines
ii  libgtk2.0-0               2.4.13-1.1     The GTK+ graphical user interface 
ii  libgtk2.0-bin             2.4.13-1.1     The programs for the GTK+ graphica
ii  libgtk2.0-common          2.4.13-1.1     Common files for the GTK+ graphica
ii  libjpeg62                 6b-9           The Independent JPEG Group's JPEG 
ii  libpango1.0-0             1.6.0-3        Layout and rendering of internatio
ii  libpng12-0                1.2.7-1        PNG library - runtime
ii  libtiff4                  3.6.1-3        Tag Image File Format library
ii  libx11-6                  4.3.0.dfsg.1-8 X Window System protocol client li
ii  libxcursor1               1.1.3-1        X cursor management library
ii  libxext6                  4.3.0.dfsg.1-8 X Window System miscellaneous exte
ii  libxft2                   2.1.2-6        FreeType-based font drawing librar
ii  libxi6                    4.3.0.dfsg.1-8 X Window System Input extension li
ii  libxrandr2                4.3.0.dfsg.1-8 X Window System Resize, Rotate and
ii  libxrender1               0.8.3-7        X Rendering Extension client libra
ii  xlibs                     4.3.0.dfsg.1-8 X Window System client libraries m
ii  zlib1g                    1:1.2.2-3      compression library - runtime

-- no debconf information

--===============0181312972==
Content-Type: text/x-c; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="003_display.patch"

diff -ruN gtk+-2.4.13.orig/gtk/gtkmain.c gtk+-2.4.13/gtk/gtkmain.c
--- gtk+-2.4.13.orig/gtk/gtkmain.c	2004-08-04 07:22:03.000000000 +0900
+++ gtk+-2.4.13/gtk/gtkmain.c	2004-11-26 18:11:29.000000000 +0900
@@ -947,6 +947,8 @@
   if (!gtk_init_check (argc, argv))
     {
       const char *display_name_arg = gdk_get_display_arg_name ();
+      if (display_name_arg == NULL)
+        display_name_arg = getenv("DISPLAY");
       g_warning ("cannot open display: %s", display_name_arg ? display_name_arg : " ");
       exit (1);
     }

--===============0181312972==--