From cdfa03ad7472eb374b2434926d058cf570bc4e37 Mon Sep 17 00:00:00 2001 From: Viktor Engelmann Date: Fri, 7 Oct 2016 13:39:47 +0200 Subject: Consider multiple contents in mimeDataFromDropData conversion content::DropData can have multiple contents (e.g. an tag has itself as .html property, but also the src="..." attribute as .url property. Therefore, we should always consider all 3 cases and not return immediately when we have found the first content. Task-number: QTBUG-55858 Change-Id: Ie13851e8edb9ada45184a19b6ccfe38839bb9923 Reviewed-by: Allan Sandfeld Jensen --- src/core/web_contents_adapter.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/core/web_contents_adapter.cpp') diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index bfac6a5b2..7285648fd 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1059,18 +1059,12 @@ void WebContentsAdapter::setWebChannel(QWebChannel *channel, uint worldId) static QMimeData *mimeDataFromDropData(const content::DropData &dropData) { QMimeData *mimeData = new QMimeData(); - if (!dropData.text.is_null()) { + if (!dropData.text.is_null()) mimeData->setText(toQt(dropData.text.string())); - return mimeData; - } - if (!dropData.html.is_null()) { + if (!dropData.html.is_null()) mimeData->setHtml(toQt(dropData.html.string())); - return mimeData; - } - if (dropData.url.is_valid()) { + if (dropData.url.is_valid()) mimeData->setUrls(QList() << toQt(dropData.url)); - return mimeData; - } return mimeData; } -- cgit v1.2.3 From 8caf750d57e9ebf7507f61951c45d3f31b5f5139 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 26 Oct 2016 11:18:36 +0200 Subject: Fix hang when dragging files from file picker onto QWebEngineView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The method WebContentsAdapter::updateDragPosition actively waits for the UpdateDragCursor message, sent by the renderer. This active wait does not work whenever we're currently in a base::MessageLoop::RunTask call, because of its internal recursion guard nestable_tasks_allowed. Add a check for nestable_tasks_allowed and bail out if we know that the active wait will fail. This fixes the hang. Ensure that the modal file picker dialog is shown outside of base::MessageLoop::RunTask. This enables drag 'n drop updates from the file picker to QWebEngineView. Task-number: QTBUG-56488 Change-Id: Ia13ada9c19e7780e12ca633ab1caeac352aca2a9 Reviewed-by: Viktor Engelmann Reviewed-by: Michael BrĂ¼ning --- src/core/web_contents_adapter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/core/web_contents_adapter.cpp') diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 7285648fd..fc54c98ed 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1159,6 +1159,16 @@ Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const Q rvh->DragTargetDragOver(toGfx(e->pos()), toGfx(screenPos), toWeb(e->possibleActions()), blink::WebInputEvent::LeftButtonDown); + base::MessageLoop *currentMessageLoop = base::MessageLoop::current(); + DCHECK(currentMessageLoop); + if (!currentMessageLoop->NestableTasksAllowed()) { + // We're already inside a MessageLoop::RunTask call, and scheduled tasks will not be + // executed. That means, updateDragAction will never be called, and the RunLoop below will + // remain blocked forever. + qWarning("WebContentsAdapter::updateDragPosition called from MessageLoop::RunTask."); + return Qt::IgnoreAction; + } + // Wait until we get notified via RenderViewHostDelegateView::UpdateDragCursor. This calls // WebContentsAdapter::updateDragAction that will eventually quit the nested loop. base::RunLoop loop; -- cgit v1.2.3