From 6e3bf7fed483639e15e492df3efd32324ca6af50 Mon Sep 17 00:00:00 2001 From: Julia Date: Wed, 5 Apr 2023 13:05:02 -0400 Subject: [PATCH] Hesitant possible fix for lock screen crash This may cause issues in this situations but as I cannot repro this I'm making the call to try something and see how it plays out --- crates/gpui/src/platform/mac/screen.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/gpui/src/platform/mac/screen.rs b/crates/gpui/src/platform/mac/screen.rs index 98b6a66f03..3766a13de3 100644 --- a/crates/gpui/src/platform/mac/screen.rs +++ b/crates/gpui/src/platform/mac/screen.rs @@ -65,8 +65,15 @@ impl platform::Screen for Screen { // This approach is similar to that which winit takes // https://github.com/rust-windowing/winit/blob/402cbd55f932e95dbfb4e8b5e8551c49e56ff9ac/src/platform_impl/macos/monitor.rs#L99 let device_description = self.native_screen.deviceDescription(); + let key = ns_string("NSScreenNumber"); let device_id_obj = device_description.objectForKey_(key); + if device_id_obj.is_null() { + // Under some circumstances, especially display re-arrangements or display locking, we seem to get a null pointer + // to the device id. See: https://linear.app/zed-industries/issue/Z-257/lock-screen-crash-with-multiple-monitors + return None; + } + let mut device_id: u32 = 0; CFNumberGetValue( device_id_obj as CFNumberRef,