Wrong error message in `gtk_init`
When gtk_init_check
fails, Gtk will always print the same error message regardless of why the function failed: https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtkmain.c#L664
if (!gtk_init_check ())
{
const char *display_name_arg;
display_name_arg = getenv ("DISPLAY");
g_warning ("cannot open display: %s", display_name_arg ? display_name_arg : "");
exit (1);
}
Steps to reproduce
Try to start any Gtk application, while forcing the Wayland backend and make it fail by setting a non-existent display:
GDK_BACKEND=wayland WAYLAND_DISPLAY=foobar-42 any-gtk-application
Current behavior
WARN [Gtk] cannot open display: :0
That error message first of all invokes the impression that Gtk tried to open the (X11) display 0, which is wrong since I requested the Wayland backend. Moreover, it being a warning leaves doubt as to whether or not this is the actual cause of failure, rather than a comorbidity.
Expected outcome
- The error message does not tell me things which are untrue
- The error message tells me why exactly
gtk_init_check
failed so that I can debug and try to fix it - The error message is printed with ERROR or FATAL severity, not WARNING
Version information
Gtk 4.10.1 Arch Linux
CC @matthiasc