From 69a5a213ddbe8b0062715d6c01b6a643e46c900a Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 10 Jan 2022 23:01:18 +0100 Subject: Fix not working web ui popup (html comboboxes) due to focus out events Recent change in qtdeclarative 42d411e2e8 causes a focus out event being delivered in case of popups to "root" item of quickwidget. This is not expected as events are forwarded to parent "view" and loosing a focus will hint Blink to trigger a pop up close request. As a communication with a render process is asynchronous this creates several race conditions in our tests and the Blink's popup close request can close unexpectedly windows creating dangling pointers. Moreover, the focus in never gained back leaving the Blink's logic in a limbo state. Simply ignore a focus out event in case of popups. Fixes: QTBUG-99215 Change-Id: I5ca6eda227101d4f19f15735e41f066cfd8ccea0 Reviewed-by: Kirill Burtsev (cherry picked from commit ba2e26f3d94f0a4bb0077bed19f2b04a7b5104f0) Reviewed-by: Qt Cherry-pick Bot --- .../render_widget_host_view_qt_delegate_widget.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index aa136b662..4fa0667b8 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -76,11 +76,16 @@ protected: } void focusInEvent(QFocusEvent *event) override { + Q_ASSERT(event->reason() != Qt::PopupFocusReason); m_client->forwardEvent(event); } void focusOutEvent(QFocusEvent *event) override { - m_client->forwardEvent(event); + // The keyboard events are supposed to go to the parent RenderHostView and WebUI + // popups should never have focus, therefore ignore focusOutEvent as losing focus + // will trigger pop close request from blink + if (event->reason() != Qt::PopupFocusReason) + m_client->forwardEvent(event); } void inputMethodEvent(QInputMethodEvent *event) override { -- cgit v1.2.3