Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

macos: Fix panic when `NSWindow::screen` returns `nil` (#38524)

Ben Kunkle4e316c683bc3
diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs
index 1230a704062..e8b42c57b82 100644
--- a/crates/gpui/src/platform/mac/window.rs
+++ b/crates/gpui/src/platform/mac/window.rs
@@ -513,10 +513,11 @@ impl MacWindowState {
fn bounds(&self) -> Bounds<Pixels> {
let mut window_frame = unsafe { NSWindow::frame(self.native_window) };
- let screen_frame = unsafe {
- let screen = NSWindow::screen(self.native_window);
- NSScreen::frame(screen)
- };
+ let screen = unsafe { NSWindow::screen(self.native_window) };
+ if screen == nil {
+ return Bounds::new(point(px(0.), px(0.)), crate::DEFAULT_WINDOW_SIZE);
+ }
+ let screen_frame = unsafe { NSScreen::frame(screen) };
// Flip the y coordinate to be top-left origin
window_frame.origin.y =