diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c index e9f8d7d663..991bc02756 100644 --- a/gtk/gtkaccessible.c +++ b/gtk/gtkaccessible.c @@ -104,13 +104,17 @@ gtk_accessible_get_at_context (GtkAccessible *self) GtkAccessibleRole gtk_accessible_get_accessible_role (GtkAccessible *self) { + GtkAccessibleRole role; + g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), GTK_ACCESSIBLE_ROLE_NONE); GtkATContext *context = gtk_accessible_get_at_context (self); - if (context == NULL) - return GTK_ACCESSIBLE_ROLE_NONE; + if (context != NULL && gtk_at_context_is_realized (context)) + return gtk_at_context_get_accessible_role (context); - return gtk_at_context_get_accessible_role (context); + g_object_get (G_OBJECT (self), "accessible-role", &role, NULL); + + return role; } /** diff --git a/gtk/gtktestatcontext.c b/gtk/gtktestatcontext.c index c8bd222d1a..27ad90da67 100644 --- a/gtk/gtktestatcontext.c +++ b/gtk/gtktestatcontext.c @@ -118,15 +118,9 @@ gboolean gtk_test_accessible_has_role (GtkAccessible *accessible, GtkAccessibleRole role) { - GtkATContext *context; - g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), FALSE); - context = gtk_accessible_get_at_context (accessible); - if (context == NULL) - return FALSE; - - return gtk_at_context_get_accessible_role (context) == role; + return gtk_accessible_get_accessible_role (accessible) == role; } gboolean