1515from extensionPoints .util import AnnotatableWeakref , BoundMethodWeakref
1616from inspect import ismethod
1717from buildVersion import version_year
18- import NVDAState
1918from watchdog import getFormattedStacksForAllThreads
2019
2120
4241 OVERLAPPED
4342 ]
4443]
45- _apcsWillBeStronglyReferenced = version_year < 2024 and NVDAState ._allowDeprecatedAPI ()
46- """
47- Starting from NVDA 2024.1, we will weakly reference functions that are executed as an APC.
48- This will ensure that objects from which APCs have been queuedwon't be scattering around
49- when the APC is never executed.
50- Wrapped methods are now strongly referenced due to an oversight in NVDA 2023.1.
51- """
5244
5345
5446def _generateApcParams () -> typing .Generator [ApcIdT , None , None ]:
@@ -147,28 +139,16 @@ def start(self):
147139 super ().start ()
148140 self .handle = ctypes .windll .kernel32 .OpenThread (winKernel .THREAD_SET_CONTEXT , False , self .ident )
149141
150- if _apcsWillBeStronglyReferenced :
151- @contextmanager
152- def autoDeleteApcReference (self , apcUuid ):
153- log .warning (
154- "IoThread.autoDeleteApcReference is deprecated. "
155- "It was never meant to be part of the public API. "
156- "This method will be removed in NVDA 2024.1. "
157- "Up until that version, it behaves as a no-op, i.e. a context manager yielding nothing."
158- )
159- yield
160-
161142 def _registerToCallAsApc (
162143 self ,
163144 func : ApcT ,
164145 param : int = 0 ,
165- _alwaysReferenceWeakly : bool = True
166146 ) -> ApcIdT :
167147 """Internal method to store a python function to be called in an Asynchronous Procedure Call (APC).
168148 The function and param are saved in a store on the IoThread instance.
169149 When our internal APC executes the function, the entry be popped from the store.
170150 This method does not queue the APC itself.
171- Note that starting from NVDA 2024.1, the saved python function will be weakly referenced,
151+ The saved python function will be weakly referenced,
172152 therefore the caller should keep a reference to the python function.
173153 @param func: The function to be called in an APC.
174154 @param param: The parameter passed to the APC when called.
@@ -179,14 +159,11 @@ def _registerToCallAsApc(
179159
180160 # generate a number to identify the function in the store.
181161 internalParam = next (self ._apcParamCounter )
182- useWeak = _alwaysReferenceWeakly or not _apcsWillBeStronglyReferenced
183- reference = None
184- if useWeak :
185- # Generate a weak reference to the function
186- reference = BoundMethodWeakref (func ) if ismethod (func ) else AnnotatableWeakref (func )
187- reference .funcName = repr (func )
162+ # Generate a weak reference to the function
163+ reference = BoundMethodWeakref (func ) if ismethod (func ) else AnnotatableWeakref (func )
164+ reference .funcName = repr (func )
188165
189- self ._apcStore [internalParam ] = (reference or func , param )
166+ self ._apcStore [internalParam ] = (reference , param )
190167 return internalParam
191168
192169 def queueAsApc (
@@ -197,7 +174,7 @@ def queueAsApc(
197174 """safely queues a Python function call as an Asynchronous Procedure Call (APC).
198175 The function and param are saved in a store on the IoThread instance.
199176 When our internal APC executes the function, the entry will be popped from the store.
200- Note that starting from NVDA 2024.1, the queued python function will be weakly referenced,
177+ The queued python function will be weakly referenced,
201178 therefore the caller should keep a reference to the python function.
202179 @param func: The function to be called in an APC.
203180 @param param: The parameter passed to the APC when called.
0 commit comments