refactor the exit of nvda and gui.terminate#12342
Conversation
lukaszgo1
left a comment
There was a problem hiding this comment.
Aside from one comment about raising WinError below this looks pretty nice. I am no longer able to reproduce crashes I've been experiencing with the previous implementation.
LeonarddeR
left a comment
There was a problem hiding this comment.
I have two concerns with the current code:
- It introduces logic to the winUser module. winUser historically was meant to wrap user32.dll functions, now there's NVDA specific stuff leaking into it. I'd like to suggest moving this to another module, windowUtils for example, though a separate module in the gui could also be considered.
- Please avoid registering the window message at the top level of a module, which will always register the message when the module is imported. This means it will try to register the message when linting, for example.
We've addressed this in favour of reverting using this custom windows message, as it's not necessary to fix the bug and this otherwise blocks the release. |
See test results for failed build of commit 6bf2942c42 |
| preNVDAExit.unregister(handler) | ||
|
|
||
|
|
||
| def closeAllWindows(): |
There was a problem hiding this comment.
It seems like this should never be called directly, only via preNVDAExit Action. If so, please add a note to the doc string.
I also think this function name should be prefixed with an underscore, as a convention to signify their "protected" state. Typically anything that we don't want add-ons to use should be prefixed with an underscore (or in a class that is named that way).
Link to issue number:
Closes #12238, #12325
Changes
Summary of the issue:
PR #12286 Introduced the following issues:
PR #12286 addressed:
When restarting NVDA,
WM_QUITis posted as an event to the window, forcibly exiting the app. This leaves objects such as the system tray icon left behind.Additionally, changes introduced in #12183
gui.terminateno longer necessary/redundantDescription of how this pull request fixes the issue:
This PR:
core.triggerNVDAExitwhich terminates necessary modules and then closes all windowsPR #12286 addressed it's issues by:
winUser.WM_EXIT_NVDAis registered that triggerssafeAppExitand can be called across instances of NVDA.safeAppExitso that it is exited properly before destructionsafeAppExitis not called fromgui.terminateif it has been called elsewhere to terminate the app.WM_QUITis the other way to exit the MainLoop other thansafeAppExitgui.terminateto process pending events as this doesn't work.Testing strategy:
nvda-old.logwhen restarting NVDA.Known issues with pull request:
WM_QUITwill not exit the app safely (called from a new NVDA instance) when a dialog such asWelcomeDialogis still openChange log entry:
None
Code Review Checklist: