From 7ee9bfc158a290776f622f62d0202220c6d159bc Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 28 Sep 2020 11:16:41 +0200 Subject: QCocoaDrag - set image only on the first drag item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This image is already a combined image of all urls that we drag. Pick-to: 5.15 Change-Id: I8fe45f64a6022881320d100f8a6f4a25fcac73b9 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoadrag.mm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 40ce461c30..f681981d34 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -216,13 +216,18 @@ 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) { 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: @@ -231,7 +236,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]; } -- cgit v1.2.3