Fix panic in update_ime_position (#21510)

This can call back into the app, so must be done when the platform lock
is not
held.

Release Notes:

- Fixes a (rare) panic when changing tab
This commit is contained in:
Conrad Irwin 2024-12-03 22:20:25 -08:00 committed by GitHub
parent 8f08787cf0
commit e231321655
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1111,10 +1111,16 @@ impl PlatformWindow for MacWindow {
}
fn update_ime_position(&self, _bounds: Bounds<ScaledPixels>) {
unsafe {
let input_context: id = msg_send![class!(NSTextInputContext), currentInputContext];
let _: () = msg_send![input_context, invalidateCharacterCoordinates];
}
let executor = self.0.lock().executor.clone();
executor
.spawn(async move {
unsafe {
let input_context: id =
msg_send![class!(NSTextInputContext), currentInputContext];
let _: () = msg_send![input_context, invalidateCharacterCoordinates];
}
})
.detach()
}
}