Skip to content

Commit 5b40621

Browse files
shanecelisjgcodes2020
authored andcommitted
macOS: fix panic during drag_window
Return error from it instead of unwrapping.
1 parent af399dc commit 5b40621

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/changelog/unreleased.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ changelog entry.
190190
### Fixed
191191

192192
- On Orbital, `MonitorHandle::name()` now returns `None` instead of a dummy name.
193-
- On macOS, fix `SurfaceEvent::Moved` sometimes being triggered unnecessarily on resize.
194-
- On MacOS, package manifest definitions of `LSUIElement` will no longer be overridden with the
193+
- On macOS, fix `WindowEvent::Moved` sometimes being triggered unnecessarily on resize.
194+
- On macOS, package manifest definitions of `LSUIElement` will no longer be overridden with the
195195
default activation policy, unless explicitly provided during initialization.
196+
- On macOS, fix crash when calling `drag_window()` without a left click present.
196197
- On X11, key events forward to IME anyway, even when it's disabled.

src/platform_impl/apple/appkit/window.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ impl CoreWindow for Window {
284284
}
285285

286286
fn drag_window(&self) -> Result<(), RequestError> {
287-
self.maybe_wait_on_main(|delegate| delegate.drag_window());
288-
Ok(())
287+
self.maybe_wait_on_main(|delegate| delegate.drag_window())
289288
}
290289

291290
fn drag_resize_window(

src/platform_impl/apple/appkit/window_delegate.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1171,10 +1171,12 @@ impl WindowDelegate {
11711171
}
11721172

11731173
#[inline]
1174-
pub fn drag_window(&self) {
1174+
pub fn drag_window(&self) -> Result<(), RequestError> {
11751175
let mtm = MainThreadMarker::from(self);
1176-
let event = NSApplication::sharedApplication(mtm).currentEvent().unwrap();
1176+
let event =
1177+
NSApplication::sharedApplication(mtm).currentEvent().ok_or(RequestError::Ignored)?;
11771178
self.window().performWindowDragWithEvent(&event);
1179+
Ok(())
11781180
}
11791181

11801182
#[inline]

0 commit comments

Comments
 (0)