fix: crash when cancelling the session manager on macOS (#2433)#2547
Open
twinn1013 wants to merge 1 commit into
Open
fix: crash when cancelling the session manager on macOS (#2433)#2547twinn1013 wants to merge 1 commit into
twinn1013 wants to merge 1 commit into
Conversation
…active Two independent crashes on macOS were hidden behind this repro, since cancelling the session manager at startup also exits the application: 1. The session manager starts an inline rename right after creating a new session. When the form was closed via Cancel, the edit link's queued async EndEditNode call fired after the tree was already destroyed, and its focus restoration ran into "[TCustomForm.SetFocus] connform:Tconnform Can not focus". Remove pending async edit calls when an editor link is destroyed, cancel a pending inline rename before the form closes, and add a SetFocusSafe() helper based on CanSetFocus, which - unlike CanFocus - also checks the parent form itself. 2. On shutdown, TSynBaseCompletionForm.Destroy (SynEdit) first frees its SizeDrag panel and then destroys the window handle. The Cocoa widgetset queries Focused during DestroyHandle, and SynEdit's Focused override dereferences the freed SizeDrag, raising "EObjectCheck: Object reference is Nil" on every macOS shutdown. Work around it by destroying the completion form's handle in FormDestroy while the form is still intact. Fixes issue 2433
Collaborator
|
Also looks ok to me. Only one thing: please prefer the existing HeidiSQL/source/apphelpers.pas Line 3781 in 8644cd7 Maybe through catching exceptions in TrySetFocus the TWinControlAccess quirk is not even required?
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent crashes on macOS were hidden behind this repro, since cancelling the session manager at startup also exits the application:
The session manager starts an inline rename right after creating a new session. When the form was closed via Cancel, the edit link's queued async EndEditNode call fired after the tree was already destroyed, and its focus restoration ran into "[TCustomForm.SetFocus] connform:Tconnform Can not focus". Remove pending async edit calls when an editor link is destroyed, cancel a pending inline rename before the form closes, and add a SetFocusSafe() helper based on CanSetFocus, which - unlike CanFocus - also checks the parent form itself.
On shutdown, TSynBaseCompletionForm.Destroy (SynEdit) first frees its SizeDrag panel and then destroys the window handle. The Cocoa widgetset queries Focused during DestroyHandle, and SynEdit's Focused override dereferences the freed SizeDrag, raising "EObjectCheck: Object reference is Nil" on every macOS shutdown. Work around it by destroying the completion form's handle in FormDestroy while the form is still intact.
Verified on an M5 MacBook Pro (macOS 26) under lldb with breakpoints on FPC_RAISEEXCEPTION / FPC_CHECK_OBJECT: before the fix both exceptions fired; after the fix the app exits cleanly with status 0.
Fixes #2433