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;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let pb = sender.draggingPasteboard();
|
let pb = sender.draggingPasteboard();
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
let filenames = pb
|
let property_list = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) {
|
||||||
.propertyListForType(unsafe { NSFilenamesPboardType })
|
Some(property_list) => property_list,
|
||||||
.unwrap()
|
None => return false.into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let paths = property_list
|
||||||
.downcast::<NSArray>()
|
.downcast::<NSArray>()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
let paths = filenames
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|file| PathBuf::from(file.downcast::<NSString>().unwrap().to_string()))
|
.map(|file| PathBuf::from(file.downcast::<NSString>().unwrap().to_string()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
@ -411,13 +414,16 @@ define_class!(
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let pb = sender.draggingPasteboard();
|
let pb = sender.draggingPasteboard();
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
let filenames = pb
|
let property_list = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) {
|
||||||
.propertyListForType(unsafe { NSFilenamesPboardType })
|
Some(property_list) => property_list,
|
||||||
.unwrap()
|
None => return false.into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let paths = property_list
|
||||||
.downcast::<NSArray>()
|
.downcast::<NSArray>()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
let paths = filenames
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|file| PathBuf::from(file.downcast::<NSString>().unwrap().to_string()))
|
.map(|file| PathBuf::from(file.downcast::<NSString>().unwrap().to_string()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
||||||
|
|
@ -272,3 +272,4 @@ changelog entry.
|
||||||
- On Web, device events are emitted regardless of cursor type.
|
- On Web, device events are emitted regardless of cursor type.
|
||||||
- On Wayland, `axis_value120` scroll events now generate `MouseScrollDelta::LineDelta`
|
- On Wayland, `axis_value120` scroll events now generate `MouseScrollDelta::LineDelta`
|
||||||
- On X11, mouse scroll button events no longer cause duplicated `WindowEvent::MouseWheel` events.
|
- 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