[orca] Fix for bug 640218 - Handle pyatspi LookupError exceptions better; more work on bug 640132.
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix for bug 640218 - Handle pyatspi LookupError exceptions better; more work on bug 640132.
- Date: Fri, 21 Jan 2011 20:28:30 +0000 (UTC)
commit ec21d18132aa07edb0037459b3ce3b996bf3009d
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date: Fri Jan 21 15:26:01 2011 -0500
Fix for bug 640218 - Handle pyatspi LookupError exceptions better; more work on bug 640132.
src/orca/event_manager.py | 8 ++------
src/orca/orca.py | 22 ++++++++++++++++++----
src/orca/script_manager.py | 15 +++++++++++----
src/orca/scripts/toolkits/Gecko/script.py | 19 ++++++++++++++-----
4 files changed, 45 insertions(+), 19 deletions(-)
---
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index 43e03b8..b638d77 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -303,13 +303,10 @@ class EventManager:
- eventType: the event type.
"""
- try:
- self._listenerCounts[eventType] -= 1
- except KeyError:
- debug.println(debug.LEVEL_SEVERE,
- "KeyError deregistering %s listener" % eventType)
+ if not eventType in self._listenerCounts:
return
+ self._listenerCounts[eventType] -= 1
if self._listenerCounts[eventType] == 0:
self.registry.deregisterEventListener(self._enqueue, eventType)
del self._listenerCounts[eventType]
@@ -453,7 +450,6 @@ class EventManager:
try:
state = event.source.getState()
except LookupError:
- debug.printException(debug.LEVEL_WARNING)
debug.println(debug.LEVEL_WARNING,
"LookupError while processing event: %s" % eType)
if eType.startswith("window:deactivate"):
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 1560cb0..a0c3b01 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -602,8 +602,13 @@ def setLocusOfFocus(event, obj, notifyScript=True, force=False):
if event and event.source and \
event.host_application and orca_state.activeScript:
currentApp = orca_state.activeScript.app
- if currentApp != event.host_application and \
- currentApp != event.source.getApplication():
+ try:
+ appList = [event.host_application, event.source.getApplication()]
+ except LookupError:
+ appList = []
+ debug.printlin(debug.LEVEL_SEVERE,
+ "orca.setLocusOfFocus() application LookupError")
+ if not currentApp in appList:
return
oldLocusOfFocus = orca_state.locusOfFocus
@@ -965,9 +970,18 @@ def keyEcho(event):
# If this keyboard event was for an object like a password text
# field, then don't echo it.
#
- if orca_state.locusOfFocus \
- and (orca_state.locusOfFocus.getRole() == pyatspi.ROLE_PASSWORD_TEXT):
+ try:
+ role = orca_state.locusOfFocus.getRole()
+ except LookupError:
+ debug.println(debug.LEVEL_SEVERE,
+ "orca.keyEcho() - locusOfFocus no longer exists")
+ setLocusOfFocus(None, None, False)
return False
+ except:
+ pass
+ else:
+ if role == pyatspi.ROLE_PASSWORD_TEXT:
+ return False
event_string = event.event_string
debug.println(debug.LEVEL_FINEST,
diff --git a/src/orca/script_manager.py b/src/orca/script_manager.py
index da0c3af..d9bba5d 100644
--- a/src/orca/script_manager.py
+++ b/src/orca/script_manager.py
@@ -108,8 +108,14 @@ class ScriptManager:
name = ''
if obj:
- attrs = dict([attr.split(':', 1) for attr in obj.getAttributes()])
- name = attrs.get('toolkit', '')
+ try:
+ attributes = obj.getAttributes()
+ except LookupError:
+ debug.println(debug.LEVEL_SEVERE,
+ "_toolkitForObject: %s no longer exists" % obj)
+ else:
+ attrs = dict([attr.split(':', 1) for attr in attributes])
+ name = attrs.get('toolkit', '')
return name
@@ -244,9 +250,10 @@ class ScriptManager:
debug.printException(debug.LEVEL_FINEST)
return
- appList = filter(lambda a: a not in desktop, self.scripts.keys())
+ appList = self.scripts.keys()
+ appList = filter(lambda a: a!= None and a not in desktop, appList)
for app in appList:
- script = self.scripts.get(app)
+ script = self.scripts.pop(app)
_eventManager.deregisterListeners(script)
del app
del script
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index ea4f110..17f3548 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -2817,12 +2817,21 @@ class Script(default.Script):
indicates that we want Firefox to handle key commands.
"""
- # If the current object isn't even showing, we don't want to hand
- # this off to Firefox's native caret navigation because who knows
- # where we'll wind up....
- #
- if obj and not obj.getState().contains(pyatspi.STATE_SHOWING):
+ try:
+ state = obj.getState()
+ except LookupError:
+ debug.println(debug.LEVEL_SEVERE,
+ "isNavigableAria() - obj no longer exists")
return True
+ except:
+ pass
+ else:
+ # If the current object isn't even showing, we don't want to hand
+ # this off to Firefox's native caret navigation because who knows
+ # where we'll wind up....
+ #
+ if state.contains(pyatspi.STATE_SHOWING):
+ return True
# Sometimes the child of an ARIA widget claims focus. It may lack
# the attributes we're looking for. Therefore, if obj is not an
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]