diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8ebc2f5dc7..8bc8c07836 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -12088,19 +12088,27 @@ gtk_widget_real_get_accessible (GtkWidget *widget) accessible = atk_object_factory_create_accessible (factory, G_OBJECT (widget)); + + if (priv->accessible_role != ATK_ROLE_INVALID) + atk_object_set_role (accessible, priv->accessible_role); + + g_object_set_qdata (G_OBJECT (widget), + quark_accessible_object, + accessible); } else { accessible = g_object_new (priv->accessible_type, NULL); + + if (priv->accessible_role != ATK_ROLE_INVALID) + atk_object_set_role (accessible, priv->accessible_role); + + g_object_set_qdata (G_OBJECT (widget), + quark_accessible_object, + accessible); + atk_object_initialize (accessible, widget); } - - if (priv->accessible_role != ATK_ROLE_INVALID) - atk_object_set_role (accessible, priv->accessible_role); - - g_object_set_qdata (G_OBJECT (widget), - quark_accessible_object, - accessible); } return accessible; }