[orca] A few more LookupError sanity checks.



commit 6ce6713dc585e6d30952a551e89d8654bdca4ad5
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Feb 1 18:16:06 2012 -0500

    A few more LookupError sanity checks.

 src/orca/flat_review.py      |   20 ++++++++++++++++++--
 src/orca/script_utilities.py |    7 +++++--
 src/orca/scripts/default.py  |    5 ++++-
 3 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/flat_review.py b/src/orca/flat_review.py
index 0486db4..e92f0c9 100644
--- a/src/orca/flat_review.py
+++ b/src/orca/flat_review.py
@@ -428,12 +428,16 @@ class ValueZone(Zone):
                     #
                     orientation = _("vertical")
                         
-            value = self.accessible.queryValue()
+            try:
+                value = self.accessible.queryValue()
+            except NotImplementedError:
+                debug.println(debug.LEVEL_FINE,
+                              'ValueZone does not implement Value interface')
             try:
                 percentValue = int((value.currentValue /
                                     (value.maximumValue - value.minimumValue))
                                    * 100.0)
-            except ZeroDivisionError:
+            except:
                 percentValue = 0
 
             if orientation:
@@ -1265,6 +1269,10 @@ class Context:
 
         # If we're at a leaf node, then we've got a good one on our hands.
         #
+        try:
+            childCount = root.childCount
+        except LookupError:
+            childCount = -1
         if root.childCount <= 0:
             return self.getZonesFromAccessible(root, rootexts)
 
@@ -1733,6 +1741,10 @@ class Context:
         Returns True if the locus of interest actually changed.
         """
 
+        if not self.lines:
+            debug.println(debug.LEVEL_FINE, 'goPrevious(): no lines in context')
+            return False
+
         moved = False
 
         if flatReviewType == Context.ZONE:
@@ -1856,6 +1868,10 @@ class Context:
                 bottom; if False, will stop on boundaries.
         """
 
+        if not self.lines:
+            debug.println(debug.LEVEL_FINE, 'goNext(): no lines in context')
+            return False
+
         moved = False
 
         if flatReviewType == Context.ZONE:
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 3823360..59a1a42 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1315,8 +1315,11 @@ class Utilities:
         # comment is here to remind us this is being done in poor taste
         # and we need to eventually clean up our act.]]]
         #
-        if not activeDescendant and obj and obj.childCount:
-            activeDescendant = obj[-1]
+        if not activeDescendant and obj and obj.childCount >= 0:
+            try:
+                activeDescendant = obj[-1]
+            except:
+                pass
 
         self._script.generatorCache[self.REAL_ACTIVE_DESCENDANT][obj] = \
             activeDescendant or obj
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index b51d50e..db81191 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3045,7 +3045,10 @@ class Script(script.Script):
 
         # Should the event source be the locusOfFocus?
         #
-        role = orca_state.locusOfFocus.getRole()
+        try:
+            role = orca_state.locusOfFocus.getRole()
+        except LookupError:
+            role = None
         if role in [pyatspi.ROLE_FRAME, pyatspi.ROLE_DIALOG]:
             frameApp = orca_state.locusOfFocus.getApplication()
             eventApp = event.source.getApplication()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]