Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when DesktopInputService.methodRequestForInput() -> getTextLocation() is called #973

Merged

Conversation

m-sasha
Copy link

@m-sasha m-sasha commented Dec 30, 2023

Fixes JetBrains/compose-multiplatform#4115

The documentation of InputMethodRequests.getTextLocation says the offset argument can be null, but in our implementation of the interface it's marked as non-null. This causes the app to crash when actually called with null:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Parameter specified as non-null is null: method 
androidx.compose.ui.platform.PlatformInput$methodRequestsForInput$1.getTextLocation, parameter offset

Proposed Changes

Mark the argument as nullable

Testing

Test: Nothing to test

@m-sasha
Copy link
Author

m-sasha commented Dec 30, 2023

Not really sure why we haven't seen this crash before, as that function exists since 2020. Maybe it's rare for it to actually be called with null.

@m-sasha m-sasha requested a review from igordmn December 30, 2023 14:43
@m-sasha m-sasha merged commit 3a2c992 into jb-main Jan 2, 2024
6 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-DesktopInputService-getTextLocation-nullability branch January 2, 2024 12:16
igordmn pushed a commit that referenced this pull request Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants