mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 04:40:04 -04:00
macOS: fix a crash when dragging non-file content onto window
Winit only supports text, thus we should ignore the rest instead of crashing.
This commit is contained in:
committed by
Kirill Chibisov
parent
f6893a4390
commit
ab4c6bfc82
@@ -42,4 +42,4 @@ changelog entry.
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- On macOS, fix crash on macOS 26 by using objc2's `relax-sign-encoding` feature.
|
- On macOS, fixed crash when dragging non-file content onto window.
|
||||||
|
|||||||
@@ -373,7 +373,10 @@ declare_class!(
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let pb: Retained<NSPasteboard> = unsafe { msg_send_id![sender, draggingPasteboard] };
|
let pb: Retained<NSPasteboard> = unsafe { msg_send_id![sender, draggingPasteboard] };
|
||||||
let filenames = pb.propertyListForType(unsafe { NSFilenamesPboardType }).unwrap();
|
let filenames = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) {
|
||||||
|
Some(filenames) => filenames,
|
||||||
|
None => return false.into(),
|
||||||
|
};
|
||||||
let filenames: Retained<NSArray<NSString>> = unsafe { Retained::cast(filenames) };
|
let filenames: Retained<NSArray<NSString>> = unsafe { Retained::cast(filenames) };
|
||||||
|
|
||||||
filenames.into_iter().for_each(|file| {
|
filenames.into_iter().for_each(|file| {
|
||||||
@@ -399,7 +402,10 @@ declare_class!(
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let pb: Retained<NSPasteboard> = unsafe { msg_send_id![sender, draggingPasteboard] };
|
let pb: Retained<NSPasteboard> = unsafe { msg_send_id![sender, draggingPasteboard] };
|
||||||
let filenames = pb.propertyListForType(unsafe { NSFilenamesPboardType }).unwrap();
|
let filenames = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) {
|
||||||
|
Some(filenames) => filenames,
|
||||||
|
None => return false.into(),
|
||||||
|
};
|
||||||
let filenames: Retained<NSArray<NSString>> = unsafe { Retained::cast(filenames) };
|
let filenames: Retained<NSArray<NSString>> = unsafe { Retained::cast(filenames) };
|
||||||
|
|
||||||
filenames.into_iter().for_each(|file| {
|
filenames.into_iter().for_each(|file| {
|
||||||
|
|||||||
Reference in New Issue
Block a user