[orca/gnome-3-4] Fix for bug 672787 - Unhandled exceptions from dead accessibles in LibreOffice Calc



commit 711b6596162bb2640af71f288564c029a04db40b
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Mar 27 17:34:15 2012 -0400

    Fix for bug 672787 - Unhandled exceptions from dead accessibles in LibreOffice Calc

 src/orca/braille_generator.py                     |   10 +++--
 src/orca/orca.py                                  |    6 ++--
 src/orca/script_utilities.py                      |   36 +++++++++++---------
 src/orca/scripts/apps/soffice/speech_generator.py |    4 +-
 src/orca/speech_generator.py                      |   14 +++++---
 5 files changed, 40 insertions(+), 30 deletions(-)
---
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index 64b1274..e56ec63 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -237,8 +237,11 @@ class BrailleGenerator(generator.Generator):
             # page tab lists might be a nice thing to include. Logged
             # as bugzilla bug 319751.]]]
             #
-            role = parent.getRole()
-            if role != pyatspi.ROLE_FILLER \
+            try:
+                role = parent.getRole()
+            except:
+                role = None
+            if role and role != pyatspi.ROLE_FILLER \
                 and role != pyatspi.ROLE_SECTION \
                 and role != pyatspi.ROLE_SPLIT_PANE \
                 and role != pyatspi.ROLE_DESKTOP_FRAME \
@@ -253,8 +256,7 @@ class BrailleGenerator(generator.Generator):
             # container for the grouped objects.  When we detect this,
             # we add the label to the overall context.]]]
             #
-            if parent.getRole() in [pyatspi.ROLE_FILLER,
-                                    pyatspi.ROLE_PANEL]:
+            if role in [pyatspi.ROLE_FILLER, pyatspi.ROLE_PANEL]:
                 label = self._script.utilities.displayedLabel(parent)
                 if label and len(label) and not label.isspace():
                     if not excludeRadioButtonGroup:
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 8f7be1a..1c28f96 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -507,10 +507,10 @@ def setLocusOfFocus(event, obj, notifyScript=True, force=False):
             debug.println(debug.LEVEL_FINE,
                           "LOCUS OF FOCUS: None event=None")
     else:
-        if not app:
-            appname = "None"
-        else:
+        try:
             appname = "'" + app.name + "'"
+        except:
+            appname = "None"
         debug.println(debug.LEVEL_FINE,
                       "LOCUS OF FOCUS: app=%s name='%s' role='%s'" \
                       % (appname,
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 3adcf14..05e2dad 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1,4 +1,4 @@
-# Orca
+
 #
 # Copyright 2010 Joanmarie Diggs.
 #
@@ -212,10 +212,14 @@ class Utilities:
 
         obj = obj.parent
         while obj and (obj != obj.parent):
-            if obj.getRole() in ancestorRoles:
+            try:
+                role = obj.getRole()
+            except:
+                break
+            if role in ancestorRoles:
                 ancestor = obj
                 break
-            elif obj.getRole() in stopRoles:
+            elif role in stopRoles:
                 break
             else:
                 obj = obj.parent
@@ -759,17 +763,21 @@ class Utilities:
 
         layoutOnly = False
 
-        if obj:
+        try:
             attributes = obj.getAttributes()
-        else:
+        except:
             attributes = None
+        try:
+            role = obj.getRole()
+        except:
+            role = None
 
-        if obj and (obj.getRole() == pyatspi.ROLE_TABLE) and attributes:
+        if role == pyatspi.ROLE_TABLE and attributes:
             for attribute in attributes:
                 if attribute == "layout-guess:true":
                     layoutOnly = True
                     break
-        elif obj and (obj.getRole() == pyatspi.ROLE_PANEL):
+        elif role == pyatspi.ROLE_PANEL:
             text = self.displayedText(obj)
             label = self.displayedLabel(obj)
             if not ((label and len(label)) or (text and len(text))):
@@ -1031,9 +1039,11 @@ class Utilities:
                     potentialLabels.append(child1)
             else:
                 parent = obj.parent
-                if parent and \
-                    ((parent.getRole() == pyatspi.ROLE_FILLER) \
-                            or (parent.getRole() == pyatspi.ROLE_PANEL)):
+                try:
+                    parentRole = parent.getRole()
+                except:
+                    parentRole = None
+                if parentRole in [pyatspi.ROLE_FILLER, pyatspi.ROLE_PANEL]:
                     for potentialLabel in parent:
                         try:
                             useLabel = self.__isLabeling(potentialLabel, obj)
@@ -1472,15 +1482,9 @@ class Utilities:
         - obj: the Accessible object
         """
 
-        debug.println(debug.LEVEL_FINEST,
-                      "Finding top-level object for source.name="
-                      + obj.name or "None")
-
         while obj and obj.parent and (obj != obj.parent) \
               and (obj.parent.getRole() != pyatspi.ROLE_APPLICATION):
             obj = obj.parent
-            debug.println(debug.LEVEL_FINEST, "--> obj.name="
-                          + obj.name or "None")
 
         if obj and obj.parent and \
            (obj.parent.getRole() == pyatspi.ROLE_APPLICATION):
diff --git a/src/orca/scripts/apps/soffice/speech_generator.py b/src/orca/scripts/apps/soffice/speech_generator.py
index 279eea0..5ba72a7 100644
--- a/src/orca/scripts/apps/soffice/speech_generator.py
+++ b/src/orca/scripts/apps/soffice/speech_generator.py
@@ -275,8 +275,8 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
         except NotImplementedError:
             parentTable = None
         index = self._script.utilities.cellIndex(obj)
-        if "lastRow" in self._script.pointOfReference and \
-           self._script.pointOfReference["lastRow"] != \
+        if "lastRow" in self._script.pointOfReference and parentTable \
+           and self._script.pointOfReference["lastRow"] != \
            parentTable.getRowAtIndex(index):
             if table in self._script.dynamicRowHeaders:
                 column = self._script.dynamicRowHeaders[table]
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 1239cda..f6dbed9 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -1568,8 +1568,12 @@ class SpeechGenerator(generator.Generator):
                             or (requireText \
                                 and 'Text' in pyatspi.listInterfaces(parent))):
                         text = self._script.utilities.displayedText(parent)
-                    if not text and parent.getRole() \
-                           in [pyatspi.ROLE_MENU, pyatspi.ROLE_PAGE_TAB]:
+                    try:
+                        pRole = parent.getRole()
+                    except:
+                        pRole = None
+                    if not text \
+                       and pRole in [pyatspi.ROLE_MENU, pyatspi.ROLE_PAGE_TAB]:
                         text = parent.name
                     if text and len(text.strip()):
                         roleInfo = self._generateRoleName(parent)
@@ -1577,12 +1581,12 @@ class SpeechGenerator(generator.Generator):
                             roleInfo.reverse()
                         # Push announcement of cell to the end
                         #
-                        if parent.getRole() not in [pyatspi.ROLE_TABLE_CELL,
-                                                    pyatspi.ROLE_FILLER]:
+                        if pRole not in \
+                               [pyatspi.ROLE_TABLE_CELL, pyatspi.ROLE_FILLER]:
                             result.extend(roleInfo)
                         result.extend(acss)
                         result.append(text)
-                        if parent.getRole() == pyatspi.ROLE_TABLE_CELL:
+                        if pRole == pyatspi.ROLE_TABLE_CELL:
                             result.extend(roleInfo)
                 parent = parent.parent
         result.reverse()



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