diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2016-11-10 15:44:46 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2016-11-11 07:45:16 +0000 |
commit | 9c982f6b654c05eb653c8d571796f52332748127 (patch) | |
tree | 458858b9c99f61b34fc928bed6087a4575131223 /src/core/web_contents_adapter.cpp | |
parent | 6c941affb2dd263d929b69afae3a0b9664869a9d (diff) |
Fix drops that originate outside the WebEngineView
Dragging things from another application onto QWebEngineView crashed.
RenderViewHost::DragTargetDrop now requires a DropData object. Save the
DropData object also in the case where we create it for a drag from
outside.
Change-Id: I8409500a4b27d06aeec02dce9856aca7e1415402
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Viktor Engelmann <viktor.engelmann@qt.io>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r-- | src/core/web_contents_adapter.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index c8d93b3f0..31ba2580f 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -351,7 +351,6 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate() , adapterClient(0) , nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd) , lastFindRequestId(0) - , currentDropData(nullptr) , currentDropAction(Qt::IgnoreAction) , inDragUpdateLoop(false) , updateDragCursorMessagePollingTimer(new QTimer) @@ -1140,15 +1139,14 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD // Clear certain fields of the drop data to not run into DCHECKs // of DropDataToWebDragData in render_view_impl.cc. - content::DropData fixedDropData = dropData; - fixedDropData.download_metadata.clear(); - fixedDropData.file_contents.clear(); - fixedDropData.file_description_filename.clear(); + d->currentDropData.reset(new content::DropData(dropData)); + d->currentDropData->download_metadata.clear(); + d->currentDropData->file_contents.clear(); + d->currentDropData->file_description_filename.clear(); d->currentDropAction = Qt::IgnoreAction; - d->currentDropData = &fixedDropData; QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation - drag->setMimeData(mimeDataFromDropData(fixedDropData)); + drag->setMimeData(mimeDataFromDropData(*d->currentDropData)); if (!pixmap.isNull()) { drag->setPixmap(pixmap); drag->setHotSpot(offset); @@ -1161,7 +1159,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); rvh->DragSourceSystemDragEnded(); - d->currentDropData = nullptr; + d->currentDropData.reset(); } static blink::WebDragOperationsMask toWeb(const Qt::DropActions action) @@ -1198,17 +1196,14 @@ void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPoint &screenPos) { Q_D(WebContentsAdapter); - std::unique_ptr<content::DropData> ownedDropData; - const content::DropData *rvhDropData = d->currentDropData; - if (!rvhDropData) { + if (!d->currentDropData) { // The drag originated outside the WebEngineView. - ownedDropData.reset(new content::DropData); - fillDropDataFromMimeData(ownedDropData.get(), e->mimeData()); - rvhDropData = ownedDropData.get(); + d->currentDropData.reset(new content::DropData); + fillDropDataFromMimeData(d->currentDropData.get(), e->mimeData()); } content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - rvh->DragTargetDragEnter(*rvhDropData, toGfx(e->pos()), toGfx(screenPos), + rvh->DragTargetDragEnter(*d->currentDropData, toGfx(e->pos()), toGfx(screenPos), toWeb(e->possibleActions()), flagsFromModifiers(e->keyboardModifiers())); } @@ -1255,6 +1250,7 @@ void WebContentsAdapter::endDragging(const QPoint &clientPos, const QPoint &scre finishDragUpdate(); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); rvh->DragTargetDrop(*d->currentDropData, toGfx(clientPos), toGfx(screenPos), 0); + d->currentDropData.reset(); } void WebContentsAdapter::leaveDrag() @@ -1263,6 +1259,7 @@ void WebContentsAdapter::leaveDrag() finishDragUpdate(); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); rvh->DragTargetDragLeave(); + d->currentDropData.reset(); } void WebContentsAdapter::initUpdateDragCursorMessagePollingTimer() |