nvda
cb356535 - WasapiWavePlayer: Don't explicitly remove the instance from the instances map in the destructor. (#15754)

Commit
2 years ago
WasapiWavePlayer: Don't explicitly remove the instance from the instances map in the destructor. (#15754) Fixes #15752. Summary of the issue: Some users sometimes see errors like this in their logs, accompanied by long freezes: ERROR - stderr (15:18:17.518) - MainThread (29504): Exception ignored in: ERROR - stderr (15:18:17.529) - MainThread (29504): <function WasapiWavePlayer.__del__ at 0x0467A6B8> ERROR - stderr (15:18:17.950) - MainThread (29504): Traceback (most recent call last): ERROR - stderr (15:18:18.392) - MainThread (29504): File "nvwave.pyc", line 843, in __del__ ERROR - stderr (15:18:18.830) - MainThread (29504): File "weakref.pyc", line 145, in __delitem__ ERROR - stderr (15:18:18.843) - MainThread (29504): KeyError ERROR - stderr (15:18:18.855) - MainThread (29504): : ERROR - stderr (15:18:19.283) - MainThread (29504): 80057872 Description of user facing changes NVDA no longer sometimes freezes when speaking a large amount of text. Description of development approach Previously, WasapiWavePlayer's __del__ method removed itself from the _instances map. However, a WeakValueDictionary actually removes the reference itself when the object dies. A weakref callback can run before __del__ in some cases, which would mean that the item was already removed, resulting in this KeyError. To fix this, we just don't explicitly remove the item and rely entirely on WeakValueDictionary to do this.
Author
Parents
Loading