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:
parent
a9c189a423
commit
82eab465e0
2 changed files with 17 additions and 10 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -272,3 +272,4 @@ changelog entry.
|
|||
- On Web, device events are emitted regardless of cursor type.
|
||||
- On Wayland, `axis_value120` scroll events now generate `MouseScrollDelta::LineDelta`
|
||||
- On X11, mouse scroll button events no longer cause duplicated `WindowEvent::MouseWheel` events.
|
||||
- On macOS, fixed crash when dragging non-file content onto window.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue