Fix panic in update_ime_position (#21510)
Conrad Irwin
created
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
Change summary
crates/gpui/src/platform/mac/window.rs | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
Detailed changes
@@ -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()
}
}