QCocoaDrag::drag - make sure clipboard is ours and populated

This fix is not final yet, it's just to plumb the serious bug/regression
of accessing NSPasteBoard in some strange state and the one we have not
populated yet/do not even own (?). Drag image(s) is broken atm and will
be fixed in the follow-up patch.

Pick-to: 5.15
Task-number: QTBUG-71939
Change-Id: I5c3ac3ec138d7407c2e0c206485478aa5244ae15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Timur Pocheptsov 2020-09-21 14:19:11 +02:00
parent 8a50a11437
commit 720e2e0c92
1 changed files with 4 additions and 4 deletions

View File

@ -130,6 +130,10 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
m_drag = o;
m_executed_drop_action = Qt::IgnoreAction;
QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
if (maybeDragMultipleItems())
return m_executed_drop_action;
@ -138,10 +142,6 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
NSImage *dragImage = [NSImage imageFromQImage:pm.toImage()];
Q_ASSERT(dragImage);
QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
NSPoint event_location = [m_lastEvent locationInWindow];
NSWindow *theWindow = [m_lastEvent window];
Q_ASSERT(theWindow);