From d42a9d19ff1ed83bdb31a62e28a5757384e05367 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Wed, 14 Feb 2018 16:59:52 +0200 Subject: Remove tst_QGLThreads::textureUploadInThread The test has been crashing flakily recently. 1) It is creating a QGLWidget 2) It is stealing the QGLContext of that widget and moves it into a separate thread. 3) In that secondary thread it makes the context current. 4) Meanwhile the QGLWidget itself may receive for example a resizeEvent or other events and - since it assumes that it owns the context - attempts to make it current. 5) Attempting to call makeCurrent() on a QGLContext that is in a different thread than the current thread (via QObject thread affinity) will result in a call to qFatal() and consequently the test aborts. The conclusion from Simon Hausmann is that this test is testing a pattern from Qt4 times that may or may not have worked back then. Nowadays with the Qt5 QOpenGL* API we do support this properly and there appears little sense testing this. Therefore remove the test altogether. Task-number: QTBUG-66411 Task-number: QTBUG-66216 Change-Id: Ie2d66705bc7c3914ace6abcba9557c7c67ad4db3 Reviewed-by: Laszlo Agocs --- tests/auto/opengl/qglthreads/tst_qglthreads.cpp | 133 ------------------------ tests/auto/opengl/qglthreads/tst_qglthreads.h | 1 - 2 files changed, 134 deletions(-) (limited to 'tests/auto/opengl') diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index 90fc4e0f2a..76186f5575 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -185,139 +185,6 @@ void tst_QGLThreads::swapInThread() QVERIFY(true); } - - - - - - -/* - textureUploadInThread - - The purpose of this testcase is to verify that doing texture uploads in a background - thread is possible and that it works. - */ - -class CreateAndUploadThread : public QThread -{ - Q_OBJECT -public: - CreateAndUploadThread(QGLWidget *shareWidget, QSemaphore *semaphore) - : m_semaphore(semaphore) - { - m_gl = new QGLWidget(0, shareWidget); - moveToThread(this); - - } - - void moveContextToThread() - { - m_gl->context()->moveToThread(this); - } - - ~CreateAndUploadThread() - { - delete m_gl; - } - - void run() { - m_gl->makeCurrent(); - QTime time; - time.start(); - while (time.elapsed() < RUNNING_TIME) { - int width = 400; - int height = 300; - QImage image(width, height, QImage::Format_RGB32); - QPainter p(&image); - p.fillRect(image.rect(), QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))); - p.setPen(Qt::red); - p.setFont(QFont("SansSerif", 24)); - p.drawText(image.rect(), Qt::AlignCenter, "This is an autotest"); - p.end(); - m_gl->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); - - m_semaphore->acquire(1); - - createdAndUploaded(image); - } - } - -signals: - void createdAndUploaded(const QImage &image); - -private: - QGLWidget *m_gl; - QSemaphore *m_semaphore; -}; - -class TextureDisplay : public QGLWidget -{ - Q_OBJECT -public: - TextureDisplay(QSemaphore *semaphore) - : m_semaphore(semaphore) - { - } - - void paintEvent(QPaintEvent *) { - QPainter p(this); - for (int i=0; ibounded(width() / 2), -QRandomGenerator::global()->bounded(height() / 2)); - - m_semaphore->release(1); - - if (m_images.size() > 100) { - m_images.takeFirst(); - m_positions.takeFirst(); - } - } - -private: - QList m_images; - QList m_positions; - - QSemaphore *m_semaphore; -}; - -void tst_QGLThreads::textureUploadInThread() -{ - if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL)) - QSKIP("No platformsupport for ThreadedOpenGL"); - - // prevent producer thread from queuing up too many images - QSemaphore semaphore(100); - TextureDisplay display(&semaphore); - CreateAndUploadThread thread(&display, &semaphore); - - connect(&thread, SIGNAL(createdAndUploaded(QImage)), &display, SLOT(receiveImage(QImage))); - - display.show(); - QVERIFY(QTest::qWaitForWindowActive(&display)); - - thread.moveContextToThread(); - thread.start(); - - while (thread.isRunning()) { - qApp->processEvents(); - } - - QVERIFY(true); -} - - - - - - /* renderInThread diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.h b/tests/auto/opengl/qglthreads/tst_qglthreads.h index 037655c60f..e4b496c163 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.h +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.h @@ -39,7 +39,6 @@ public: private slots: void swapInThread(); - void textureUploadInThread(); void renderInThread_data(); void renderInThread(); -- cgit v1.2.3