diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-18 12:59:54 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-18 13:02:22 +0100 |
commit | c2447a308882ba3691d66b2c28df197f571518c7 (patch) | |
tree | c6535d8e038a517f06ddbef9fee649412555b8ae /src/core/web_contents_adapter.cpp | |
parent | b63a932bbe1eb2bdf2584e44378ac3fab243320c (diff) | |
parent | 42c6033724e2b5a54702d626c57806e53f163c62 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: If16bfc6f0fbfd0040e13a8a3cbaa113fda10f387
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r-- | src/core/web_contents_adapter.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 228c37010..9de2085ba 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1171,6 +1171,12 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD d->currentDropAction = Qt::IgnoreAction; QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation + bool dValid = true; + QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){ + dValid = false; + QDrag::cancel(); + }); + drag->setMimeData(mimeDataFromDropData(*d->currentDropData)); if (!pixmap.isNull()) { drag->setPixmap(pixmap); @@ -1182,9 +1188,15 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD drag->exec(allowedActions); } - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - rvh->DragSourceSystemDragEnded(); - d->currentDropData.reset(); + QObject::disconnect(onDestroyed); + if (dValid) { + if (d->webContents) { + content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); + if (rvh) + rvh->DragSourceSystemDragEnded(); + } + d->currentDropData.reset(); + } } static blink::WebDragOperationsMask toWeb(const Qt::DropActions action) |