summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoss Heim <moss.heim@qt.io>2024-09-10 17:23:09 +0200
committerMichael BrĂ¼ning <michael.bruning@qt.io>2024-10-01 07:45:23 +0000
commit7496ee3d28a6734aaf5fffbd883fe77a5ca68d19 (patch)
treeeafade868b2f2a516dbf533d7abc46ab290fca91
parente069922db24784746ff2da822420f76e14a06adf (diff)
Fix crash with popups over transparent backgrounds
An earlier color update fix (dcc464b14c) caused color updates to be applied to views without owner delegates, in the case of combo box popups for example. We now guard this pointer dereference. Pick-to: tqtc/lts-6.5 Fixes: QTBUG-128241 Change-Id: Ib086c7d544b29bf41101ff423160de2310890174 Reviewed-by: Michal Klocek <michal.klocek@qt.io> (cherry picked from commit 9dae13cca7e06ea16db015aa35e61cc77e16951a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 12c02121d802b1314558afbf111153b55f121bca) Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
-rw-r--r--src/core/render_widget_host_view_qt.cpp2
-rw-r--r--tests/auto/widgets/qwebenginepage/CMakeLists.txt1
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp24
3 files changed, 26 insertions, 1 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 81817442a..43840ff58 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -386,7 +386,7 @@ void RenderWidgetHostViewQt::UpdateBackgroundColor()
m_rootLayer->SetColor(color);
m_uiCompositor->SetBackgroundColor(color);
- if (color == SK_ColorTRANSPARENT)
+ if (color == SK_ColorTRANSPARENT && host()->owner_delegate())
host()->owner_delegate()->SetBackgroundOpaque(false);
}
diff --git a/tests/auto/widgets/qwebenginepage/CMakeLists.txt b/tests/auto/widgets/qwebenginepage/CMakeLists.txt
index a15bb6e06..e26a0165b 100644
--- a/tests/auto/widgets/qwebenginepage/CMakeLists.txt
+++ b/tests/auto/widgets/qwebenginepage/CMakeLists.txt
@@ -9,6 +9,7 @@ qt_internal_add_test(tst_qwebenginepage
tst_qwebenginepage.cpp
LIBRARIES
Qt::CorePrivate
+ Qt::GuiPrivate
Qt::NetworkPrivate
Qt::WebEngineCorePrivate
Qt::WebEngineWidgets
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 748d9f494..e831f2a56 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -41,6 +41,8 @@
# include <QStateMachine>
#endif
#include <QtGui/QClipboard>
+#include <QtGui/qpa/qplatformintegration.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtTest/QtTest>
#include <QTextCharFormat>
#if QT_CONFIG(webengine_webchannel)
@@ -259,6 +261,7 @@ private Q_SLOTS:
void renderProcessCrashed();
void renderProcessPid();
void backgroundColor();
+ void popupOnTransparentBackground();
void audioMuted();
void closeContents();
void isSafeRedirect_data();
@@ -5024,6 +5027,27 @@ void tst_QWebEnginePage::backgroundColor()
QTRY_COMPARE(view.grab().toImage().pixelColor(center), Qt::green);
}
+void tst_QWebEnginePage::popupOnTransparentBackground()
+{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(
+ QPlatformIntegration::WindowActivation))
+ QSKIP("Cannot test on platforms without window activation capability");
+
+ QWebEngineView view;
+ view.resize(640, 480);
+ view.page()->setBackgroundColor(Qt::transparent);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QSignalSpy spyLoadFinished(&view, SIGNAL(loadFinished(bool)));
+ view.setHtml(QLatin1String("<html><head></head><body><select id='foo' name='meow'>"
+ "<option>fran</option><option>troz</option>"
+ "</select></body></html>"));
+ QTRY_COMPARE(spyLoadFinished.size(), 1);
+ makeClick(view.windowHandle(), false, elementCenter(view.page(), "foo"));
+ QPointer<QWidget> popup;
+ QTRY_VERIFY((popup = QApplication::activePopupWidget()));
+}
+
void tst_QWebEnginePage::audioMuted()
{
QWebEngineProfile profile;