From 0a46baeb5684533c7300b6b5212a7fd080f71d98 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 22 Nov 2020 18:39:39 +0000 Subject: [PATCH 1/2] a11y: Turn critical warnings into debug messages The accessibility bus might not be available, and if it isn't the case, it means something has failed at a level where the user can't do much about it. There's no need to emit a critical warning. --- gtk/a11y/gtkatspicontext.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index 10eecbdfe4..3216c33a40 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -1598,7 +1598,7 @@ get_bus_address_dbus (GdkDisplay *display) if (error != NULL) { - g_critical ("Unable to acquire session bus: %s", error->message); + GTK_NOTE (A11Y, g_message ("Unable to acquire session bus: %s", error->message)); g_error_free (error); return NULL; } @@ -1615,8 +1615,8 @@ get_bus_address_dbus (GdkDisplay *display) &error); if (error != NULL) { - g_critical ("Unable to acquire the address of the accessibility bus: %s", - error->message); + GTK_NOTE (A11Y, g_message ("Unable to acquire the address of the accessibility bus: %s", + error->message)); g_error_free (error); } From ef86e46238df288cccc2addf58512d010279192d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 22 Nov 2020 18:40:50 +0000 Subject: [PATCH 2/2] a11y: Cache the accessibility bus address Just check for it once; doing it every time we failed to create an ATContext is just going to fill up the logs. --- gtk/a11y/gtkatspicontext.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index 3216c33a40..46b157a3fa 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -1711,9 +1711,17 @@ gtk_at_spi_create_context (GtkAccessibleRole accessible_role, g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), NULL); g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); - const char *bus_address = get_bus_address (display); + static const char *bus_address; if (bus_address == NULL) + { + bus_address = get_bus_address (display); + + if (bus_address == NULL) + bus_address = ""; + } + + if (*bus_address == '\0') return NULL; #if defined(GDK_WINDOWING_WAYLAND)