diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoadrag.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoadrag.mm | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index a506126c72..2af9b8f556 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -217,13 +217,24 @@ bool QCocoaDrag::maybeDragMultipleItems() // 0. We start from URLs, which can be actually in a list (thus technically // only ONE item in the pasteboard. The fact it's only one does not help, we are // still getting an exception because of the number of items/images mismatch ... + // We only set the image for the first item and nil for the rest, the image already + // contains a combined picture for all urls we drag. + auto imageOrNil = dragImage; for (const auto &qtUrl : qtUrls) { + if (!qtUrl.isValid()) + continue; + + if (qtUrl.isRelative()) // NSPasteboardWriting rejects such items. + continue; + NSURL *nsUrl = qtUrl.toNSURL(); auto *newItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:nsUrl] autorelease]; const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y, dragImage.size.width, dragImage.size.height); - [newItem setDraggingFrame:itemFrame contents:dragImage]; + + [newItem setDraggingFrame:itemFrame contents:imageOrNil]; + imageOrNil = nil; [dragItems addObject:newItem]; } // 1. Repeat for non-url items, if any: @@ -232,7 +243,7 @@ bool QCocoaDrag::maybeDragMultipleItems() const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y, dragImage.size.width, dragImage.size.height); - [newItem setDraggingFrame:itemFrame contents:dragImage]; + [newItem setDraggingFrame:itemFrame contents:imageOrNil]; [dragItems addObject:newItem]; } |