Skip to content

Commit b32dc37

Browse files
Merge pull request #57 from wadamek65/macos-crash-workaround
fix: workaround for crash on certain MacOS systems
1 parent 6770148 commit b32dc37

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.changes/fix-drag-crash-intel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"drag": patch
3+
---
4+
5+
Fix crash on macOS systems running Intel or older macOS releases.

crates/drag/src/platform_impl/macos/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::ffi::{c_char, c_void};
66

77
use cocoa::{
8-
appkit::{NSAlignmentOptions, NSApp, NSEvent, NSEventModifierFlags, NSEventType, NSImage},
8+
appkit::{NSApp, NSEvent, NSEventModifierFlags, NSEventType, NSImage},
99
base::{id, nil},
1010
foundation::{NSArray, NSData, NSPoint, NSRect, NSSize, NSUInteger},
1111
};
@@ -63,8 +63,7 @@ pub fn start_drag<W: HasRawWindowHandle, F: Fn(DragResult, CursorPosition) + Sen
6363
// wry replaces the ns_view so we don't really use AppKitWindowHandle::ns_view
6464
let ns_view: id = msg_send![window, contentView];
6565

66-
let mouse_location: NSPoint = msg_send![window, mouseLocationOutsideOfEventStream];
67-
let current_position: NSPoint = msg_send![ns_view, backingAlignedRect: NSRect::new(mouse_location, NSSize::new(0., 0.)) options: NSAlignmentOptions::NSAlignAllEdgesOutward];
66+
let current_position: NSPoint = msg_send![window, mouseLocationOutsideOfEventStream];
6867

6968
let img: id = msg_send![class!(NSImage), alloc];
7069
let img: id = match image {
@@ -285,7 +284,11 @@ pub fn start_drag<W: HasRawWindowHandle, F: Fn(DragResult, CursorPosition) + Sen
285284
(*source).set_ivar("on_drop_ptr", callback_ptr as *mut _ as *mut c_void);
286285
(*source).set_ivar(
287286
"animate_on_cancel_or_failure",
288-
!options.skip_animatation_on_cancel_or_failure,
287+
if options.skip_animatation_on_cancel_or_failure {
288+
YES
289+
} else {
290+
NO
291+
},
289292
);
290293

291294
let _: () = msg_send![ns_view, beginDraggingSessionWithItems: dragging_items event: drag_event source: source];

0 commit comments

Comments
 (0)