macOS: fix panic during drag_window

Return error from it instead of unwrapping.
This commit is contained in:
Shane Celis
2024-10-22 07:00:53 -04:00
committed by Kirill Chibisov
parent 107bf91a2d
commit 485ae90aae
3 changed files with 373 additions and 2 deletions

View File

@@ -1163,7 +1163,8 @@ impl WindowDelegate {
#[inline]
pub fn drag_window(&self) -> Result<(), ExternalError> {
let mtm = MainThreadMarker::from(self);
let event = NSApplication::sharedApplication(mtm).currentEvent().unwrap();
let event =
NSApplication::sharedApplication(mtm).currentEvent().ok_or(ExternalError::Ignored)?;
self.window().performWindowDragWithEvent(&event);
Ok(())
}