Fix SAPI4 IBM TTS Chinese (#17903)
Summary of the issue:
NVDA is frozen when switching between IBM TTS Chinese voices.
Description of user facing changes
The issue should be fixed.
The first fix for IBM TTS Chinese was introduced in 2025.1 and the previous SAPI4 fix broke it again, so this PR is targeted to beta.
Description of development approach
Remove references to the _ComThreadTask object before transferring and re-raising the exception object to prevent circular references. The exception object contains the function frames, which contains the local variables, and task is one of them. So when the exception object is also stored in task, a circular reference is formed. While they will eventually be cleared by garbage collector, this delays the destruction of the previous TTS engine object. IBM TTS Chinese does not allow two TTS engine object to exist at the same time, thus causing errors. This fix deletes task in the finally block before raising the exception.