[orca] Handle more instances of the undead (zombies); start handling the dead



commit 08a7bbb2222948d726d1439b60606000e37760a6
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Nov 19 15:44:20 2015 -0500

    Handle more instances of the undead (zombies); start handling the dead

 src/orca/orca.py             |   16 +++++++++-------
 src/orca/script_utilities.py |    9 +++++++++
 src/orca/scripts/default.py  |   17 ++++++++++++++++-
 3 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/src/orca/orca.py b/src/orca/orca.py
index dfe031c..61c7e48 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -161,13 +161,15 @@ def setLocusOfFocus(event, obj, notifyScript=True, force=False):
         orca_state.locusOfFocus = None
         return
 
-    try:
-        app = obj.getApplication()
-    except:
-        msg = "ERROR: Exception getting application for %s" % obj
-        debug.println(debug.LEVEL_INFO, msg)
-        orca_state.locusOfFocus = None
-        return
+    if orca_state.activeScript:
+        if orca_state.activeScript.utilities.isZombie(obj):
+            msg = "ERROR: New locusOfFocus (%s) is zombie. Not updating." % obj
+            debug.println(debug.LEVEL_INFO, msg)
+            return
+        if orca_state.activeScript.utilities.isDead(obj):
+            msg = "ERROR: New locusOfFocus (%s) is dead. Not updating." % obj
+            debug.println(debug.LEVEL_INFO, msg)
+            return
 
     msg = "INFO: Changing locusOfFocus from %s to %s" % (oldFocus, obj)
     debug.println(debug.LEVEL_INFO, msg)
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 2e5fba5..5d509e2 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2943,6 +2943,15 @@ class Utilities:
 
         return False
 
+    def isDead(self, obj):
+        try:
+            name = obj.name
+        except:
+            debug.println(debug.LEVEL_INFO, "DEAD: %s" % obj)
+            return True
+
+        return False
+
     def isZombie(self, obj):
         try:
             index = obj.getIndexInParent()
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 168e2f5..5964710 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -2166,6 +2166,13 @@ class Script(script.Script):
             self.toggleFlatReviewMode()
 
         text = event.source.queryText()
+        try:
+            caretOffset = text.caretOffset
+        except:
+            msg = "DEFAULT: Exception getting caretOffset for %s" % event.source
+            debug.println(debug.LEVEL_INFO, msg)
+            return
+
         self._saveLastCursorPosition(event.source, text.caretOffset)
         if text.getNSelections():
             msg = "DEFAULT: Event source has text selections"
@@ -2409,7 +2416,15 @@ class Script(script.Script):
             if iconified:
                 return
 
-        if obj and obj.childCount and obj.getRole() != pyatspi.ROLE_COMBO_BOX:
+        try:
+            childCount = obj.childCount
+            role = obj.getRole()
+        except:
+            msg = "DEFAULT: Exception getting childCount and role for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg)
+            return
+
+        if childCount and role != pyatspi.ROLE_COMBO_BOX:
             selectedChildren = self.utilities.selectedChildren(obj)
             if selectedChildren:
                 obj = selectedChildren[0]


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