mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 14:49:07 -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:
@@ -353,13 +353,16 @@ define_class!(
|
||||
use std::path::PathBuf;
|
||||
|
||||
let pb = sender.draggingPasteboard();
|
||||
|
||||
#[allow(deprecated)]
|
||||
let filenames = pb
|
||||
.propertyListForType(unsafe { NSFilenamesPboardType })
|
||||
.unwrap()
|
||||
let property_list = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) {
|
||||
Some(property_list) => property_list,
|
||||
None => return false.into(),
|
||||
};
|
||||
|
||||
let paths = property_list
|
||||
.downcast::<NSArray>()
|
||||
.unwrap();
|
||||
let paths = filenames
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|file| PathBuf::from(file.downcast::<NSString>().unwrap().to_string()))
|
||||
.collect();
|
||||
@@ -411,13 +414,16 @@ define_class!(
|
||||
use std::path::PathBuf;
|
||||
|
||||
let pb = sender.draggingPasteboard();
|
||||
|
||||
#[allow(deprecated)]
|
||||
let filenames = pb
|
||||
.propertyListForType(unsafe { NSFilenamesPboardType })
|
||||
.unwrap()
|
||||
let property_list = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) {
|
||||
Some(property_list) => property_list,
|
||||
None => return false.into(),
|
||||
};
|
||||
|
||||
let paths = property_list
|
||||
.downcast::<NSArray>()
|
||||
.unwrap();
|
||||
let paths = filenames
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|file| PathBuf::from(file.downcast::<NSString>().unwrap().to_string()))
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user