mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Fix panic in window open (#4148)
Fix a panic caused by toggleFullScreen on one window untoggling full-screen on another. I managed to reproduce this only once, which makes me sad, but this change should fix it regardless. https://zed-industries.slack.com/archives/C04S6T1T7TQ/p1705631681238979 Release Notes: - Fixed an occasional panic when opening a new fullscreen window.
This commit is contained in:
commit
2166f071b3
@ -516,25 +516,6 @@ impl MacWindow {
|
||||
NSArray::arrayWithObject(nil, NSFilenamesPboardType)
|
||||
];
|
||||
|
||||
let screen = native_window.screen();
|
||||
match options.bounds {
|
||||
WindowBounds::Fullscreen => {
|
||||
native_window.toggleFullScreen_(nil);
|
||||
}
|
||||
WindowBounds::Maximized => {
|
||||
native_window.setFrame_display_(screen.visibleFrame(), YES);
|
||||
}
|
||||
WindowBounds::Fixed(bounds) => {
|
||||
let display_bounds = display.bounds();
|
||||
let frame = if bounds.intersects(&display_bounds) {
|
||||
display_bounds_to_native(bounds)
|
||||
} else {
|
||||
display_bounds_to_native(display_bounds)
|
||||
};
|
||||
native_window.setFrame_display_(mem::transmute::<CGRect, NSRect>(frame), YES);
|
||||
}
|
||||
}
|
||||
|
||||
let native_view: id = msg_send![VIEW_CLASS, alloc];
|
||||
let native_view = NSView::init(native_view);
|
||||
|
||||
@ -656,6 +637,27 @@ impl MacWindow {
|
||||
native_window.orderFront_(nil);
|
||||
}
|
||||
|
||||
let screen = native_window.screen();
|
||||
match options.bounds {
|
||||
WindowBounds::Fullscreen => {
|
||||
// We need to toggle full screen asynchronously as doing so may
|
||||
// call back into the platform handlers.
|
||||
window.toggle_full_screen()
|
||||
}
|
||||
WindowBounds::Maximized => {
|
||||
native_window.setFrame_display_(screen.visibleFrame(), YES);
|
||||
}
|
||||
WindowBounds::Fixed(bounds) => {
|
||||
let display_bounds = display.bounds();
|
||||
let frame = if bounds.intersects(&display_bounds) {
|
||||
display_bounds_to_native(bounds)
|
||||
} else {
|
||||
display_bounds_to_native(display_bounds)
|
||||
};
|
||||
native_window.setFrame_display_(mem::transmute::<CGRect, NSRect>(frame), YES);
|
||||
}
|
||||
}
|
||||
|
||||
window.0.lock().move_traffic_light();
|
||||
pool.drain();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user