a11y: Realize GtkStackPage parent context before trying to get a ref
authorSebastian Keller <skeller@gnome.org>
Wed, 25 May 2022 12:56:05 +0000 (14:56 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 27 May 2022 11:21:49 +0000 (07:21 -0400)
If a context is not realized, calling gtk_at_spi_context_to_ref() will
return a null ref, because its path has not been initialized yet. This
was already done for all other cases in get_parent_context_ref(), but
was missing for the GtkStackPage case.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4944
gtk/a11y/gtkatspicontext.c

index 7c49929affa6dcd988462ff62a5ab542571e2b2f..a0086365c441c0aac530f6c6a8787ed3fb857cf7 100644 (file)
@@ -436,7 +436,11 @@ get_parent_context_ref (GtkAccessible *accessible)
         gtk_accessible_get_at_context (GTK_ACCESSIBLE (parent));
 
       if (parent_context != NULL)
-        res = gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (parent_context));
+        {
+          gtk_at_context_realize (parent_context);
+
+          res = gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (parent_context));
+        }
     }
 
   if (res == NULL)