From 5f10a415d7547fe6c1a25fa5594491991cef7f5d Mon Sep 17 00:00:00 2001 From: Akemi Date: Sun, 29 Jan 2017 18:54:59 +0100 Subject: cocoa: fix dropping of files and URLs the problem here is that dropped files can also be treated as NSURLPboardType instead of just NSFilenamesPboardType. the 'else if' could never be reached and was dead code. this basically reverts ed695ce which tried to fix multiple dropped URLs, or rather files, and moves the filename check infront of the URL check. the filename path can handle multiple dropped files, whereas the URL path can only handle one dropped URL. this assumes that only one URL can be dropped at a time. it also reverts a603543 because it's not needed any more. this also fixes a problem where dropped URLs from Chrome don't conform to the NSURL class and the readObjectsForClasses method always returned an empty URL. Fixes #4036 --- video/out/cocoa/events_view.m | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index 3bf7bd44f4..f76ca0d617 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -313,23 +313,14 @@ - (BOOL)performDragOperation:(id )sender { NSPasteboard *pboard = [sender draggingPasteboard]; - if ([[pboard types] containsObject:NSURLPboardType]) { - NSArray *pbitems = [pboard readObjectsForClasses:@[[NSURL class]] - options:@{}]; - NSMutableArray* ar = [[[NSMutableArray alloc] init] autorelease]; - for (NSURL* url in pbitems) { - if ([url isFileURL]) { - [ar addObject:[url path]]; - } else { - [ar addObject:[url absoluteString]]; - } - } - [self.adapter handleFilesArray:ar]; - return YES; - } else if ([[pboard types] containsObject:NSFilenamesPboardType]) { + if ([[pboard types] containsObject:NSFilenamesPboardType]) { NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType]; [self.adapter handleFilesArray:pbitems]; return YES; + } else if ([[pboard types] containsObject:NSURLPboardType]) { + NSURL *url = [NSURL URLFromPasteboard:pboard]; + [self.adapter handleFilesArray:@[[url absoluteString]]]; + return YES; } return NO; } -- cgit v1.2.3