mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-08 08:37:42 +00:00
Fixes #7690. When kmshell.dpr is being shut down by Windows via `WM_ENDSESSION`, the order of termination of units through `finalization` sections means that `IdStackWindows` was finalizing while components were still depending on it, causing a cascade of exceptions resulting eventually in the crash visible in #7690. We saw this when there were message loops before `Application.Run` had ever been called. For example, message box/dialog, ShellExecute (yep... this can do a `PeekMessage`), `THttpUploader` (which calls `Application.ProcessMessages`) and probably others. Ideally, it would be better to always call `Application.Run`, but it is not safe to call `Application.Run` more than once, because it ends up adding multiple `DoneApplication` exit procs, which would likely cause other crashes. I landed on the somewhat heavy-handed solution of adding `IdStackWindows` to the start of the project `uses` list, ensuring it is the last unit to be finalized -- importantly, before `Vcl.Forms`. A better solution would be to find a way of ensuring that `Application.Run` is called, just once, in all situations, but this is likely to be hard to achieve. The shutdown sequence for Delphi apps is so very, very fragile. |
||
|---|---|---|
| .. | ||
| include | ||
| src | ||