From ad2466f2faf56b949c8550394d7035e916abbad9 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sun, 22 Apr 2018 18:53:49 +0200 Subject: [PATCH] WebView: Fix finding correct rwhvqt Focus proxy is actually set only after adding it to the layout, so without the timer it would pick old rwhvqt. BUG: 393398 --- src/lib/webengine/webview.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index ee846bf66..28228a856 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -1292,12 +1292,16 @@ bool WebView::eventFilter(QObject *obj, QEvent *event) } // Hack to find widget that receives input events - if (obj == this && event->type() == QEvent::ChildAdded && !m_rwhvqt && focusProxy()) { - m_rwhvqt = focusProxy(); - m_rwhvqt->installEventFilter(this); - if (QQuickWidget *w = qobject_cast(m_rwhvqt)) { - w->setClearColor(palette().color(QPalette::Window)); - } + if (obj == this && event->type() == QEvent::ChildAdded) { + QTimer::singleShot(0, this, [this]() { + if (focusProxy() && m_rwhvqt != focusProxy()) { + m_rwhvqt = focusProxy(); + m_rwhvqt->installEventFilter(this); + if (QQuickWidget *w = qobject_cast(m_rwhvqt)) { + w->setClearColor(palette().color(QPalette::Window)); + } + } + }); } // Forward events to WebView