void QOpenGLContext::doneCurrent()
{
Q_D(QOpenGLContext);
- if (!isValid())
- return;
- if (QOpenGLContext::currentContext() == this)
- d->shareGroup->d_func()->deletePendingResources(this);
+ if (isValid()) {
+ if (QOpenGLContext::currentContext() == this)
+ d->shareGroup->d_func()->deletePendingResources(this);
+ d->platformGLContext->doneCurrent();
+ }
- d->platformGLContext->doneCurrent();
QOpenGLContextPrivate::setCurrentContext(nullptr);
d->surface = nullptr;
void bufferCreate();
void bufferMapRange();
void defaultQGLCurrentBuffer();
+#if QT_CONFIG(egl)
+ void dontCrashOnInvalidContextThreadTeardown();
+#endif
};
struct SharedResourceTracker
//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"