[orca] Fix crash caused by author using aria-labelled by pointing to itself



commit cdb405166f0854dfd53933211c013906bcfff111
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Jun 9 10:11:42 2020 -0400

    Fix crash caused by author using aria-labelled by pointing to itself

 src/orca/braille_generator.py | 14 +++++---------
 src/orca/script_utilities.py  |  4 ++++
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index 1a3e92e26..4e5921e7a 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -432,15 +432,11 @@ class BrailleGenerator(generator.Generator):
         details.
         """
         result = []
-        try:
-            relations = obj.getRelationSet()
-        except:
-            relations = []
-        for relation in relations:
-            if relation.getRelationType() ==  pyatspi.RELATION_LABELLED_BY:
-                labelledBy = relation.getTarget(0)
-                result.extend(self.generate(labelledBy, **args))
-                break
+        labels = self._script.utilities.labelsForObject(obj)
+        for label in labels:
+            result.extend(self.generate(label, **args))
+            break
+
         if not result:
             # NOTE: there is no REAL_ROLE_SCROLL_PANE in formatting.py
             # because currently fallback to the default formatting.
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index f5d3db5b1..06609551e 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1731,6 +1731,10 @@ class Utilities:
 
         r = relations[0]
         result = set([r.getTarget(i) for i in range(r.getNTargets())])
+        if obj in result:
+            msg = 'WARNING: %s claims to be labelled by itself' % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            result.remove(obj)
 
         def isNotAncestor(acc):
             return not pyatspi.findAncestor(obj, lambda x: x == acc)


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