diff options
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) |