diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-09-28 11:16:41 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-09-28 21:43:47 +0200 |
commit | 7ee9bfc158a290776f622f62d0202220c6d159bc (patch) | |
tree | 3b9692b5a37ce6679602c073b45742de8e065995 /src/plugins/platforms/cocoa | |
parent | bfd07072fed89c10470560efe2ab545c56c302e0 (diff) |
QCocoaDrag - set image only on the first drag item
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ø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoadrag.mm | 9 |
1 files changed, 7 insertions, 2 deletions
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]; } |