atspi_accessible_get_application will walk up the tree until it finds a child
of the desktop, but this causes it to return the wrong accessible if an
object's parent is set to NULL for whatever reason, so check for this and
return the object's root accessible in that case.
for (;;)
{
parent = atspi_accessible_get_parent (obj, NULL);
+ if (!parent &&
+ atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
+ {
+ AtspiAccessible *root = g_object_ref (obj->parent.app->root);
+ if (root)
+ {
+ g_object_unref (obj);
+ return root;
+ }
+ }
if (!parent || parent == obj ||
atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
return obj;