diff options
author | David Redondo <[email protected]> | 2025-01-15 13:52:13 +0100 |
---|---|---|
committer | David Redondo <[email protected]> | 2025-01-24 19:36:07 +0100 |
commit | cd1686e55f706048286cbc962bbe02032c2396cd (patch) | |
tree | 47014c67d02ceb25b7f1854581e9b0c065ddeb3b /tests/auto/gui/qopengl/tst_qopengl.cpp | |
parent | 48dbc72c4467d120353dba46fdbc2f8ddc145629 (diff) |
QOpenGlContext: Always unset current context in doneCurrent()
Otherwise when no other context is made current until thread exit, the
QGuiGLThreadContext destructor will try to call doneCurrent() on an
already deleted context.
Pick-to: 6.9 6.8
Change-Id: If55dd69a72b8ab4012780a449f6a02729dd0ed43
Reviewed-by: Laszlo Agocs <[email protected]>
Diffstat (limited to 'tests/auto/gui/qopengl/tst_qopengl.cpp')
-rw-r--r-- | tests/auto/gui/qopengl/tst_qopengl.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index af59f3e31a3..3f4aa8cd8f9 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -84,6 +84,9 @@ private slots: void bufferCreate(); void bufferMapRange(); void defaultQGLCurrentBuffer(); +#if QT_CONFIG(egl) + void dontCrashOnInvalidContextThreadTeardown(); +#endif }; struct SharedResourceTracker @@ -1751,6 +1754,31 @@ void tst_QOpenGL::clipRect() //QCOMPARE(fb.pixelColor(clipRect.right(), clipRect.top() + 1), QColor(Qt::red)); } +#if QT_CONFIG(egl) +void tst_QOpenGL::dontCrashOnInvalidContextThreadTeardown() +{ + class Thread : public QThread + { + void run() override + { + auto context = std::make_unique<QOpenGLContext>(); + QVERIFY(context->create()); + QScopedPointer<QSurface> surface(createSurface(int(QSurface::Window))); + QVERIFY(context->makeCurrent(surface.data())); + auto eglContext = context->nativeInterface<QNativeInterface::QEGLContext>(); + if (!eglContext) { + QSKIP("Need an egl context for this test"); + } + eglContext->invalidateContext(); + context->doneCurrent(); + } + }; + Thread thread; + thread.start(); + thread.wait(); +} +#endif + QTEST_MAIN(tst_QOpenGL) #include "tst_qopengl.moc" |