Skip to content

Commit

Permalink
Fix crash with popups over transparent backgrounds
Browse files Browse the repository at this point in the history
An earlier color update fix (dcc464b) 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 6.8
Change-Id: Ib086c7d544b29bf41101ff423160de2310890174
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
  • Loading branch information
Moss Heim committed Sep 19, 2024
1 parent 8581bed commit 9dae13c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/render_widget_host_view_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,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);
}

Expand Down
1 change: 1 addition & 0 deletions tests/auto/widgets/qwebenginepage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ qt_internal_add_test(tst_qwebenginepage
tst_qwebenginepage.cpp
LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
Qt::NetworkPrivate
Qt::WebEngineCorePrivate
Qt::WebEngineWidgets
Expand Down
24 changes: 24 additions & 0 deletions tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -267,6 +269,7 @@ private Q_SLOTS:
void renderProcessCrashed();
void renderProcessPid();
void backgroundColor();
void popupOnTransparentBackground();
void audioMuted();
void closeContents();
void isSafeRedirect_data();
Expand Down Expand Up @@ -5343,6 +5346,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;
Expand Down

0 comments on commit 9dae13c

Please sign in to comment.