gpui: Avoid dereferencing null pointer in MacWindow::update_ime_position (#28110)

Seems to be very similar to
https://github.com/zed-industries/zed/pull/28059

Edit: Updated the reproduction-steps as I missed something.

The method without a check currently causes my debug-builds to crash on
the regular if I:
- Run a debug build and open it fullscreen in a dedicated space on my
Mac.
- Work on any of the built-in languages (e.g. remove some content from
any `highlights.scm`)
- Reopen the workspace with the debug-build.
- Crash.

~~We might actually be able to revert the changes made in
https://github.com/zed-industries/zed/pull/21510 and just add the
null-check. Then again, I am not at all sure whether that would work.­~~
See comment below.

Release Notes:

- N/A
This commit is contained in:
Finn Evers 2025-04-05 00:20:06 +02:00 committed by GitHub
parent 288da0f072
commit 8b077f0c41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1161,6 +1161,9 @@ impl PlatformWindow for MacWindow {
unsafe {
let input_context: id =
msg_send![class!(NSTextInputContext), currentInputContext];
if input_context.is_null() {
return;
}
let _: () = msg_send![input_context, invalidateCharacterCoordinates];
}
})