Skip to content

Commit 1034ff0

Browse files
authored
Merge ce0ea35 into cc66269
2 parents cc66269 + ce0ea35 commit 1034ff0

4 files changed

Lines changed: 9 additions & 93 deletions

File tree

source/bdDetect.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
import re
4242
from winAPI import messageWindow
4343
import extensionPoints
44-
import NVDAState
45-
from buildVersion import version_year
4644
from logHandler import log
4745

4846

@@ -105,39 +103,6 @@ def _isDebug():
105103
return config.conf["debugLog"]["hwIo"]
106104

107105

108-
if version_year < 2024 and NVDAState._allowDeprecatedAPI():
109-
def addUsbDevices(driver: str, type: str, ids: Set[str]):
110-
"""Associate USB devices with a driver.
111-
@param driver: The name of the driver.
112-
@param type: The type of the driver, either C{KEY_HID}, C{KEY_SERIAL} or C{KEY_CUSTOM}.
113-
@param ids: A set of USB IDs in the form C{"VID_xxxx&PID_XXXX"}.
114-
Note that alphabetical characters in hexadecimal numbers should be uppercase.
115-
@raise ValueError: When one of the provided IDs is malformed.
116-
"""
117-
log.warning(
118-
"bdDetect.addUsbDevices is deprecated and will be removed in NVDA 2024.1. "
119-
"Braille display drivers should implement the registerAutomaticDetection classmethod instead. "
120-
"That method receives a DriverRegistrar object on which the addUsbDevices method can be used."
121-
)
122-
registrar = DriverRegistrar(driver)
123-
registrar.addUsbDevices(type, ids)
124-
125-
def addBluetoothDevices(driver: str, matchFunc: MatchFuncT):
126-
"""Associate Bluetooth HID or COM ports with a driver.
127-
@param driver: The name of the driver.
128-
@param matchFunc: A function which determines whether a given Bluetooth device matches.
129-
It takes a L{DeviceMatch} as its only argument
130-
and returns a C{bool} indicating whether it matched.
131-
"""
132-
log.warning(
133-
"bdDetect.addBluetoothDevices is deprecated and will be removed in NVDA 2024.1. "
134-
"Braille display drivers should implement the registerAutomaticDetection classmethod instead. "
135-
"That method receives a DriverRegistrar object on which the addBluetoothDevices method can be used."
136-
)
137-
registrar = DriverRegistrar(driver)
138-
registrar.addBluetoothDevices(matchFunc)
139-
140-
141106
def getDriversForConnectedUsbDevices(
142107
limitToDevices: Optional[List[str]] = None
143108
) -> Iterator[Tuple[str, DeviceMatch]]:

source/braille.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
from autoSettingsUtils.driverSetting import BooleanDriverSetting, NumericDriverSetting
6363
from utils.security import objectBelowLockScreenAndWindowsIsLocked
6464
import hwIo
65-
from buildVersion import version_year
66-
import NVDAState
6765

6866
if TYPE_CHECKING:
6967
from NVDAObjects import NVDAObject
@@ -2481,15 +2479,6 @@ def handleCaretMove(
24812479
# The caret moved in a different object than the review position.
24822480
self._doNewObject(getFocusRegions(obj, review=False))
24832481

2484-
if version_year < 2024 and NVDAState._allowDeprecatedAPI():
2485-
def handlePendingCaretUpdate(self):
2486-
log.warning(
2487-
"braille.BrailleHandler.handlePendingCaretUpdate is now deprecated "
2488-
"with no public replacement. "
2489-
"It will be removed in NVDA 2024.1."
2490-
)
2491-
self._handlePendingUpdate()
2492-
24932482
def _handlePendingUpdate(self):
24942483
"""When any region is pending an update, updates the region and the braille display.
24952484
"""
@@ -2827,12 +2816,6 @@ def check(cls) -> bool:
28272816
"""
28282817
if cls.isThreadSafe:
28292818
supportsAutomaticDetection = cls.supportsAutomaticDetection
2830-
if not supportsAutomaticDetection and NVDAState._allowDeprecatedAPI() and version_year < 2024:
2831-
log.warning(
2832-
"Starting from NVDA 2024.1, drivers that rely on bdDetect for the default check method "
2833-
"should have supportsAutomaticDetection set to True"
2834-
)
2835-
supportsAutomaticDetection = True
28362819
if supportsAutomaticDetection and bdDetect.driverHasPossibleDevices(cls.name):
28372820
return True
28382821
try:

source/hwIo/base.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from logHandler import log
2626
import config
2727
import time
28-
from .ioThread import IoThread, _apcsWillBeStronglyReferenced
28+
from .ioThread import IoThread
2929
import NVDAState
3030

3131

@@ -95,10 +95,7 @@ def _initialRead(self):
9595
ioThread = self._ioThreadRef()
9696
if not ioThread:
9797
raise RuntimeError("I/O thread is no longer available")
98-
if _apcsWillBeStronglyReferenced:
99-
ioThread.queueAsApc(self._asyncReadBackwardsCompat)
100-
else:
101-
ioThread.queueAsApc(self._asyncRead)
98+
ioThread.queueAsApc(self._asyncRead)
10299

103100
def waitForRead(self, timeout:Union[int, float]) -> bool:
104101
"""Wait for a chunk of data to be received and processed.
@@ -178,12 +175,6 @@ def _asyncRead(self, param: Optional[int] = None):
178175
ioThread.queueAsCompletionRoutine(self._ioDone, self._readOl)
179176
)
180177

181-
if _apcsWillBeStronglyReferenced:
182-
def _asyncReadBackwardsCompat(self, param: Optional[int] = None):
183-
"""Backwards compatible wrapper around L{_asyncRead} that calls it without param.
184-
"""
185-
self._asyncRead()
186-
187178
def _ioDone(self, error, numberOfBytes: int, overlapped):
188179
if not self._onReceive:
189180
# close has been called.

source/hwIo/ioThread.py

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from extensionPoints.util import AnnotatableWeakref, BoundMethodWeakref
1616
from inspect import ismethod
1717
from buildVersion import version_year
18-
import NVDAState
1918
from watchdog import getFormattedStacksForAllThreads
2019

2120

@@ -42,13 +41,6 @@
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

5446
def _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,12 +174,12 @@ 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.
204181
"""
205-
internalParam = self._registerToCallAsApc(func, param, _alwaysReferenceWeakly=False)
182+
internalParam = self._registerToCallAsApc(func, param)
206183
ctypes.windll.kernel32.QueueUserAPC(self._internalApc, self.handle, internalParam)
207184

208185
def setWaitableTimer(

0 commit comments

Comments
 (0)