[orca] Handle document going defunct on us when looking for obscuring banners



commit 01d10a0ab9c1053c878b554fb1d9288010b8039f
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Nov 5 11:36:54 2019 -0500

    Handle document going defunct on us when looking for obscuring banners

 src/orca/eventsynthesizer.py | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/orca/eventsynthesizer.py b/src/orca/eventsynthesizer.py
index d939218ea..43ecb3b0a 100644
--- a/src/orca/eventsynthesizer.py
+++ b/src/orca/eventsynthesizer.py
@@ -330,6 +330,22 @@ def _containingDocument(obj):
 
     return document
 
+def _getAccessibleAtPoint(root, x, y):
+    try:
+        result = root.queryComponent().getAccessibleAtPoint(x, y, pyatspi.WINDOW_COORDS)
+    except NotImplementedError:
+        msg = "ERROR: Component interface not implemented for %s" % root
+        debug.println(debug.LEVEL_INFO, msg, True)
+        return None
+    except:
+        msg = "ERROR: Exception getting accessible at (%i, %i) for %s" % (x, y, root)
+        debug.println(debug.LEVEL_INFO, msg, True)
+        return None
+
+    msg = "EVENT SYNTHESIZER: Accessible at (%i, %i) in %s: %s" % (x, y, root, result)
+    debug.println(debug.LEVEL_INFO, msg, True)
+    return result
+
 def _obscuringBanner(obj):
     document = _containingDocument(obj)
     if not document and "Component" in pyatspi.listInterfaces(document):
@@ -338,15 +354,8 @@ def _obscuringBanner(obj):
     objX, objY, objWidth, objHeight = _objectExtents(obj)
     docX, docY, docWidth, docHeight = _objectExtents(document)
 
-    component = document.queryComponent()
-    left = component.getAccessibleAtPoint(docX, objY, pyatspi.WINDOW_COORDS)
-    msg = "EVENT SYNTHESIZER: Accessible at (%i, %i): %s" % (docX, objY, left)
-    debug.println(debug.LEVEL_INFO, msg, True)
-
-    right = component.getAccessibleAtPoint(docX + docWidth, objY, pyatspi.WINDOW_COORDS)
-    msg = "EVENT SYNTHESIZER: Accessible at (%i, %i): %s" % (docX + docWidth, objY, right)
-    debug.println(debug.LEVEL_INFO, msg, True)
-
+    left = _getAccessibleAtPoint(document, docX, objY)
+    right = _getAccessibleAtPoint(document, docX + docWidth, objY)
     if not (left and right and left == right != document):
         msg = "EVENT SYNTHESIZER: No obscuring banner found for %s" % obj
         debug.println(debug.LEVEL_INFO, msg, True)


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