Fix for BGO#648059: get_application should return something w/ROLE_APPLICATION
authorMike Gorse <mgorse@novell.com>
Mon, 18 Apr 2011 10:07:14 +0000 (05:07 -0500)
committerMike Gorse <mgorse@novell.com>
Mon, 18 Apr 2011 10:07:14 +0000 (05:07 -0500)
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.

atspi/atspi-accessible.c

index 05d2e16..86f47d8 100644 (file)
@@ -719,6 +719,16 @@ atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
   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;