summaryrefslogtreecommitdiffstats
diff options
authorMoss Heim <moss.heim@qt.io>2024-09-10 17:23:09 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-09-24 07:27:02 +0000
commitc48f3f39b52e793d1f9499e098d250b77464abf4 (patch)
treee1fb0ee7690f152d99379b1929a889da64169cb1
parent42073aabed039369c1ae6367ee60961062c8dd1d (diff)
Fix crash with popups over transparent backgrounds6.7
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. Fixes: QTBUG-128241 Pick-to: 6.7.3 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)
-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 0defad04a..145494151 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;