From 74b4d48768e9088ffbe05c8f91cd647721dea1b2 Mon Sep 17 00:00:00 2001 From: wwalker Date: Sun, 13 Jan 2008 00:02:01 +0000 Subject: [PATCH] Fix for bug 503091 - getApplication doesn't fallback properly. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@978 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- pyatspi/ChangeLog | 5 +++++ pyatspi/accessible.py | 28 ++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/pyatspi/ChangeLog b/pyatspi/ChangeLog index 4971361..d32e838 100644 --- a/pyatspi/ChangeLog +++ b/pyatspi/ChangeLog @@ -1,3 +1,8 @@ +2009-01-12 Willie Walker + + * accessible.py: fix for bug 503091 - getApplication doesn't + fallback properly. + 2007-12-13 Eitan Isaacson * accessible.py (_getAndCache): Cleaned up: Fixed indent width and diff --git a/pyatspi/accessible.py b/pyatspi/accessible.py index 4413b3b..9394857 100644 --- a/pyatspi/accessible.py +++ b/pyatspi/accessible.py @@ -603,9 +603,9 @@ class _AccessibleMixin(object): def getApplication(self): ''' - Gets the most-parent accessible (the application) of this accessible. Tries - using the getApplication method introduced in AT-SPI 1.7.0 first before - resorting to traversing parent links. + Gets the most-parent accessible (the application) of this + accessible. Tries using the getApplication method introduced in + AT-SPI 1.7.0 first before resorting to traversing parent links. @warning: Cycles involving more than the previously traversed accessible are not detected by this code. @@ -613,18 +613,26 @@ class _AccessibleMixin(object): @rtype: Accessibility.Application ''' try: - return self._mix_getApplication() + app = self._mix_getApplication() except AttributeError: - pass + app = None + + # Some toolkits (e.g., Java) do not support getApplication yet and + # will return None as a result. + # + if app: + return app + + # If we didn't find anything, traverse up the tree, making sure to + # attempt to turn the thing we found into an Application object. + # curr = self try: while curr.parent is not None and (not curr.parent == curr): curr = curr.parent - return curr - except Exception: - pass - # return None if the application isn't reachable for any reason - return None + return curr._narrow(Accessibility.Application) + except: + return None class _RelationMixin(object): ''' -- 2.7.4