QCocoaDrag: don't add pasteboard items with non-absolute URLs

AppKit rejects them and we end up with inconsistent number of pasteboard
items and drag images:

"NSURLs written to the pasteboard via NSPasteboardWriting must be absolute URLs."
"There are 1 items on the pasteboard, but 2 drag images."

Fixes: QTBUG-105711
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I7b1bc99f6e0b2b304f92f69125fb6af4ab5e303f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Timur Pocheptsov 2022-08-19 15:08:01 +02:00
parent 1270284f8d
commit da951c9dbf
1 changed files with 6 additions and 0 deletions

View File

@ -184,6 +184,12 @@ bool QCocoaDrag::maybeDragMultipleItems()
// 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,