Fix LT-22295: Don't crash if MakeDefaultSelection is called early#484
Conversation
There was a problem hiding this comment.
Pull Request Overview
Fixes a crash in the FocusBoxController when MakeDefaultSelection is called before InterlinWordControl is initialized. The fix adds null checking and defers the operation to the idle queue if the control is not ready yet.
- Added null checking for InterlinWordControl before calling MakeDefaultSelection
- Implemented deferred execution using the idle queue when the control is not yet available
- Used null-conditional operator for safety in the deferred callback
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| InterlinWordControl?.MakeDefaultSelection(); | ||
| return true; |
There was a problem hiding this comment.
The lambda function always returns true regardless of whether MakeDefaultSelection() was actually called. Consider returning a meaningful value that indicates whether the operation was successful, or add error handling if the InterlinWordControl is still null when the deferred operation executes.
| InterlinWordControl?.MakeDefaultSelection(); | |
| return true; | |
| if (InterlinWordControl != null) | |
| { | |
| InterlinWordControl.MakeDefaultSelection(); | |
| return true; | |
| } | |
| else | |
| { | |
| // Optionally log or handle the error here. | |
| // System.Diagnostics.Debug.WriteLine("InterlinWordControl is still null in deferred MakeDefaultSelection."); | |
| return false; | |
| } |
mark-sil
left a comment
There was a problem hiding this comment.
@mark-sil reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jasonleenaylor)
mark-sil
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jasonleenaylor)
This change is