Skip to content

Commit 4e316c6

Browse files
authored
macos: Fix panic when NSWindow::screen returns nil (#38524)
Closes #ISSUE Release Notes: - mac: Fixed an issue where Zed would panic if the workspace window was previously off screen
1 parent 1afbfcb commit 4e316c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/gpui/src/platform/mac/window.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,11 @@ impl MacWindowState {
513513

514514
fn bounds(&self) -> Bounds<Pixels> {
515515
let mut window_frame = unsafe { NSWindow::frame(self.native_window) };
516-
let screen_frame = unsafe {
517-
let screen = NSWindow::screen(self.native_window);
518-
NSScreen::frame(screen)
519-
};
516+
let screen = unsafe { NSWindow::screen(self.native_window) };
517+
if screen == nil {
518+
return Bounds::new(point(px(0.), px(0.)), crate::DEFAULT_WINDOW_SIZE);
519+
}
520+
let screen_frame = unsafe { NSScreen::frame(screen) };
520521

521522
// Flip the y coordinate to be top-left origin
522523
window_frame.origin.y =

0 commit comments

Comments
 (0)