diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-12-11 17:55:06 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-12-12 21:28:01 +0000 |
commit | 81986f13eb5b7dfb4bc51aeef58a77b05df643ae (patch) | |
tree | 41200744dea0dbed6e07a70bc0fee0951b131615 | |
parent | c11a437299fd7ed6eda6c3c4570d731cf037d427 (diff) |
GLWidget: disconnect during destruction and cleanup
The GLWidget instance cleans up its data structures when the OpenGL
context is about to be destroyed, but the context might be destroyed as
part of destroying the GLWidget (typically when the QOpenGLWidget
destructor runs).
To prevent that the cleanup() function gets called after the GLWidget
destructor has run (which triggers the assert in QObject), disconnect
explicitly.
The crash reproduces with any of the tests using a QAbstractSeries
implementation when the useOpenGL property is set, so add a data-row
to one of them that provokes the assert without the fix.
Fixes: QTBUG-119900
Pick-to: 6.5
Change-Id: Ib4badd0c5df68ed60df6f492cada7954f0cb220a
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
(cherry picked from commit 5c4ddaae03e720cceb853a4d5574fa4755e66aad)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit be3f2005f1d05edf7ecf9f3e5ece6aa4dd1c13a9)
-rw-r--r-- | src/charts/glwidget.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qlineseries/tst_qlineseries.cpp | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/charts/glwidget.cpp b/src/charts/glwidget.cpp index 93659a0e..ab543888 100644 --- a/src/charts/glwidget.cpp +++ b/src/charts/glwidget.cpp @@ -75,6 +75,8 @@ void GLWidget::cleanup() m_seriesBufferMap.clear(); doneCurrent(); + + context()->disconnect(this); } void GLWidget::cleanXYSeriesResources(const QXYSeries *series) diff --git a/tests/auto/qlineseries/tst_qlineseries.cpp b/tests/auto/qlineseries/tst_qlineseries.cpp index 1379322f..79bde9fb 100644 --- a/tests/auto/qlineseries/tst_qlineseries.cpp +++ b/tests/auto/qlineseries/tst_qlineseries.cpp @@ -50,12 +50,17 @@ void tst_QLineSeries::cleanup() void tst_QLineSeries::qlineseries_data() { + QTest::addColumn<bool>("useOpenGL"); + QTest::addRow("Without OpenGL") << false; + QTest::addRow("With OpenGL") << true; } void tst_QLineSeries::qlineseries() { + QFETCH(const bool, useOpenGL); QLineSeries series; + series.setUseOpenGL(useOpenGL); QCOMPARE(series.count(),0); QCOMPARE(series.brush(), QBrush()); |