[orca] Handle component interface failures in label inference



commit b4ab04e561882d1d7f64a1cccd58d0968a8b0f4f
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Oct 15 16:53:58 2018 +0200

    Handle component interface failures in label inference

 src/orca/label_inference.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/label_inference.py b/src/orca/label_inference.py
index fdfd355cd..b5573f3f2 100644
--- a/src/orca/label_inference.py
+++ b/src/orca/label_inference.py
@@ -233,8 +233,16 @@ class LabelInference:
                 extents = text.getRangeExtents(startOffset, endOffset, 0)
 
         if not (extents[2] and extents[3]):
-            ext = obj.queryComponent().getExtents(0)
-            extents = ext.x, ext.y, ext.width, ext.height
+            try:
+                ext = obj.queryComponent().getExtents(0)
+            except NotImplementedError:
+                msg = "INFO: %s does not implement the component interface" % obj
+                debug.println(debug.LEVEL_INFO, msg, True)
+            except:
+                msg = "ERROR: Exception getting extents for %s" % obj
+                debug.println(debug.LEVEL_INFO, msg, True)
+            else:
+                extents = ext.x, ext.y, ext.width, ext.height
 
         self._extentsCache[(hash(obj), startOffset, endOffset)] = extents
         return extents


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