diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2022-08-19 15:08:01 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2022-08-23 07:59:19 +0200 |
commit | da951c9dbf091b15e76fa63055a299e29a9001ad (patch) | |
tree | 1bab41f4dc068b81f80095770dfe60ca9fc75586 /src/plugins/platforms/cocoa | |
parent | 1270284f8dc753205034e7958c2a4063d1d15a7b (diff) |
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>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoadrag.mm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 50f094716f..b6c2e15ee2 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -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, |