Skip to content

Commit 7a677ca

Browse files
authored
Merge d6b348c into 36a74bd
2 parents 36a74bd + d6b348c commit 7a677ca

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

source/NVDAObjects/__init__.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import brailleInput
3232
import locationHelper
3333
import aria
34+
from typing import Optional
35+
3436

3537
class NVDAObjectTextInfo(textInfos.offsets.OffsetsTextInfo):
3638
"""A default TextInfo which is used to enable text review of information about widgets that don't support text content.
@@ -365,26 +367,31 @@ def _get_treeInterceptorClass(self):
365367
#: @type: bool
366368
shouldCreateTreeInterceptor = True
367369

368-
def _get_treeInterceptor(self):
369-
"""Retrieves the treeInterceptor associated with this object.
370-
If a treeInterceptor has not been specifically set, the L{treeInterceptorHandler} is asked if it can find a treeInterceptor containing this object.
371-
@return: the treeInterceptor
372-
@rtype: L{treeInterceptorHandler.TreeInterceptor}
370+
def _get_runningTreeInterceptor(self) -> Optional[treeInterceptorHandler.TreeInterceptor]:
371+
"""Retrieves a running treeInterceptor associated with this object.
372+
@return: the treeInterceptor or C{None} if a treeInterceptor has not been specifically set.
373373
"""
374-
if hasattr(self,'_treeInterceptor'):
375-
ti=self._treeInterceptor
376-
if isinstance(ti,weakref.ref):
377-
ti=ti()
374+
if hasattr(self, '_treeInterceptor'):
375+
ti = self._treeInterceptor
376+
if isinstance(ti, weakref.ref):
377+
ti = ti()
378378
if ti and ti in treeInterceptorHandler.runningTable:
379379
return ti
380380
else:
381381
self._treeInterceptor=None
382382
return None
383-
else:
384-
ti=treeInterceptorHandler.getTreeInterceptor(self)
383+
384+
def _get_treeInterceptor(self) -> Optional[treeInterceptorHandler.TreeInterceptor]:
385+
"""Retrieves the treeInterceptor associated with this object.
386+
If a treeInterceptor has not been specifically set, the L{treeInterceptorHandler} is asked if it can find a treeInterceptor containing this object.
387+
@return: the treeInterceptor
388+
"""
389+
ti = self.runningTreeInterceptor
390+
if not ti:
391+
ti = treeInterceptorHandler.getTreeInterceptor(self)
385392
if ti:
386-
self._treeInterceptor=weakref.ref(ti)
387-
return ti
393+
self._treeInterceptor = weakref.ref(ti)
394+
return ti
388395

389396
def _set_treeInterceptor(self,obj):
390397
"""Specifically sets a treeInterceptor to be associated with this object.

source/eventHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def gen(self, eventName, obj):
128128
yield func, (obj, self.next)
129129

130130
# Tree interceptor level.
131-
treeInterceptor = obj.treeInterceptor
131+
treeInterceptor = obj.runningTreeInterceptor
132132
if treeInterceptor:
133133
func = getattr(treeInterceptor, funcName, None)
134134
if func and (getattr(func,'ignoreIsReady',False) or treeInterceptor.isReady):

0 commit comments

Comments
 (0)