Rate limiting against gui crash (#19686)
Fixes #19634
### Summary of the issue:
Windows throws errors when rapidly requesting a window handle on the
secure desktop.
This cause visual tearing and a crash of NVDA.
### Description of user facing changes:
Avoid crash and tearing of controls
### Description of developer facing changes:
Add custom handling of changing settings categories for secure mode.
### Description of development approach:
This pull request introduces a debounced category change mechanism in
the `NVDASettingsDialog` to improve stability and user experience,
particularly when running on a secure desktop.
* Added a debounce mechanism (50ms delay) for handling category changes
in `NVDASettingsDialog` when running on a secure desktop, using a timer
to prevent rapid or duplicate category switches. This helps avoid
potential issues with UI responsiveness or event handling in secure
desktop environments.
[[1]](diffhunk://#diff-6486e3db41b2272c03b84758b460cc4269d5ca218874391f58633f5d9b3968b1R6131-R6133)
[[2]](diffhunk://#diff-6486e3db41b2272c03b84758b460cc4269d5ca218874391f58633f5d9b3968b1L6193-R6234)
* Introduced the use of `isRunningOnSecureDesktop` from `utils.security`
to determine when to apply the debounce logic.
* Added type annotations to the `onCategoryChange` method and new
internal variables for better code clarity and maintainability.
[[1]](diffhunk://#diff-6486e3db41b2272c03b84758b460cc4269d5ca218874391f58633f5d9b3968b1L748-R749)
[[2]](diffhunk://#diff-6486e3db41b2272c03b84758b460cc4269d5ca218874391f58633f5d9b3968b1R6131-R6133)
* Ensured proper cleanup of the debounce timer and related state in the
`Destroy` method to prevent resource leaks.
An alternative approach with error suppression was tried, but visual
tearing still occurred.
https://github.com/nvaccess/nvda/compare/try-gui-crash-2?expand=1
### Testing strategy:
Tested STR in #19634
### Known issues with pull request:
Other instances may exist of rapidly requesting a window handle.
Should this be reported to wxWidgets or microsoft?
Should we create a generic monkey patch or something?
From basic investigating, the only real way to cause this could be
through updating controls in the settings dialog, or the config profiles
dialog.