Merge pull request #1341 from zed-industries/mitigate-refcell-panics

Mitigate `RefCell` panics
This commit is contained in:
Antonio Scandurra
2022-07-13 10:52:21 +02:00
committed by GitHub
+25 -7
View File
@@ -392,17 +392,33 @@ impl platform::Window for Window {
});
let block = block.copy();
let native_window = self.0.borrow().native_window;
let _: () = msg_send![
alert,
beginSheetModalForWindow: native_window
completionHandler: block
];
self.0
.borrow()
.executor
.spawn(async move {
let _: () = msg_send![
alert,
beginSheetModalForWindow: native_window
completionHandler: block
];
})
.detach();
done_rx
}
}
fn activate(&self) {
unsafe { msg_send![self.0.borrow().native_window, makeKeyAndOrderFront: nil] }
let window = self.0.borrow().native_window;
self.0
.borrow()
.executor
.spawn(async move {
unsafe {
let _: () = msg_send![window, makeKeyAndOrderFront: nil];
}
})
.detach();
}
fn set_title(&mut self, title: &str) {
@@ -786,7 +802,7 @@ extern "C" fn view_did_change_backing_properties(this: &Object, _: Sel) {
extern "C" fn set_frame_size(this: &Object, _: Sel, size: NSSize) {
let window_state = unsafe { get_window_state(this) };
let mut window_state_borrow = window_state.as_ref().borrow_mut();
let window_state_borrow = window_state.as_ref().borrow();
if window_state_borrow.size() == vec2f(size.width as f32, size.height as f32) {
return;
@@ -806,6 +822,8 @@ extern "C" fn set_frame_size(this: &Object, _: Sel, size: NSSize) {
let _: () = msg_send![window_state_borrow.layer, setDrawableSize: drawable_size];
}
drop(window_state_borrow);
let mut window_state_borrow = window_state.borrow_mut();
if let Some(mut callback) = window_state_borrow.resize_callback.take() {
drop(window_state_borrow);
callback();