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:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user