aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-12-19 21:52:05 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-12-23 00:10:50 +0100
commit0d342e83123b27befde95fc35760a358dbff0b16 (patch)
tree45babc77fffd4cef1e72abdd1aa075b3b2c0f07f /tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
parent71471cce344768a5e3250fbba3ac5d3c40fb61bc (diff)
QQuickWidget: Clean up if RHI goes away under our feet
The QQuickWidget doesn't normally own the RHI; the QWidgetRepaintManager does, via QBackingStoreRhiSupport. If the top level widget is destroyed, so is its QBackingStore, and the corresponding RHI. But the QQuickWidget may outlive its top level parent, in which case it needs to update its cached reference to the RHI, and do proper cleanup before it goes away. QRhiWidget already does the same thing, for the same use-case. This was observed when recreating the top level QWidget via destroy/create as part of the RHI widget compositor logic. Fixes: QTBUG-119760 Pick-to: 6.7 6.6 6.5 Change-Id: Ic44449abcfe4271660a3ac4e132d0c4a71a21b65 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp')
-rw-r--r--tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
index fde6945ede..0c88c71582 100644
--- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
+++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
@@ -138,6 +138,7 @@ private slots:
#endif
void focusPreserved();
void accessibilityHandlesViewChange();
+ void cleanupRhi();
private:
QPointingDevice *device = QTest::createTouchDevice();
@@ -1027,6 +1028,24 @@ void tst_qquickwidget::accessibilityHandlesViewChange()
(void)iface->child(0);
}
+class CreateDestroyWidget : public QWidget
+{
+public:
+ using QWidget::create;
+ using QWidget::destroy;
+};
+
+void tst_qquickwidget::cleanupRhi()
+{
+ CreateDestroyWidget topLevel;
+ QQuickWidget quickWidget(&topLevel);
+ quickWidget.setSource(testFileUrl("rectangle.qml"));
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ topLevel.destroy();
+ topLevel.create();
+}
QTEST_MAIN(tst_qquickwidget)