[orca] Event Manager: Try to detect and avoid selection-changed event flood



commit 7d68129b0c7f80c36a781d0999cfbeb81eb98501
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Feb 26 14:55:20 2021 +0100

    Event Manager: Try to detect and avoid selection-changed event flood
    
    Apps like Caja seem to like to flood us with active-descendant-changed
    and selection-changed events. We are already ignoring the former based
    on the supposed new active descendant being defunct. We were also
    trying to catch this condition and ignore the selection-changed flood,
    but were returning early when the active-descendant was already dead.
    Its death short-circuited the remaining logic. Therefore, don't return
    quite so early for dead descendants so that we can add the spammy
    offender to the list of objects destroying children.

 src/orca/event_manager.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index 6c3f465b4..67f497c24 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -247,22 +247,26 @@ class EventManager:
                 msg = 'EVENT MANAGER: Locus of focus is being destroyed'
                 debug.println(debug.LEVEL_INFO, msg, True)
                 return False
+
             try:
                 childState = event.any_data.getState()
                 childRole = event.any_data.getRole()
                 name = event.any_data.name
+                defunct = False
             except:
                 msg = 'ERROR: Event any_data contains potentially-defunct child/descendant'
                 debug.println(debug.LEVEL_INFO, msg, True)
-                return True
+                defunct = True
+            else:
+                defunct = childState.contains(pyatspi.STATE_DEFUNCT)
+                if defunct:
+                    msg = 'ERROR: Event any_data contains defunct child/descendant'
+                    debug.println(debug.LEVEL_INFO, msg, True)
 
-            if childState.contains(pyatspi.STATE_DEFUNCT):
+            if defunct:
                 if state.contains(pyatspi.STATE_MANAGES_DESCENDANTS) \
                    and event.source not in self._parentsOfDefunctDescendants:
                     self._parentsOfDefunctDescendants.append(event.source)
-
-                msg = 'ERROR: Event any_data contains defunct child/descendant'
-                debug.println(debug.LEVEL_INFO, msg, True)
                 return True
 
             if event.source in self._parentsOfDefunctDescendants:


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