summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2016-10-26 11:18:36 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2016-10-26 11:10:29 +0000
commit8caf750d57e9ebf7507f61951c45d3f31b5f5139 (patch)
treeaa77fb9a37fecf393aab369e799433ba79aa3a40 /src/core/web_contents_adapter.cpp
parent37c8b107743465053182d4e0169f42bbd804dafe (diff)
Fix hang when dragging files from file picker onto QWebEngineView
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 <viktor.engelmann@qt.io> Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp10
1 files changed, 10 insertions, 0 deletions
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;