summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-01-04 14:17:45 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-05 02:17:04 +0100
commit07edbd23ed774c4f0331bb92d35add77fe91769c (patch)
tree68ae5318d26799949b90d13ab01ceb400dc27fa9 /tests/auto
parent8ed53babb9713103bdfd70659b147c89c711c6da (diff)
downloadqtbase-07edbd23ed774c4f0331bb92d35add77fe91769c.tar.gz
Introduced QOpenGLContext::aboutToBeDestroyed() signal.
This signal can be used to clean up OpenGL resources in a safe way before the context is destroyed. Task-number: QTBUG-20083 Change-Id: I45a4be01b06af4ee7196fa502116f099d50afeab Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index aa3e70a047..d6c587b65e 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -50,6 +50,8 @@
#include <QtTest/QtTest>
+#include <QSignalSpy>
+
class tst_QOpenGL : public QObject
{
Q_OBJECT
@@ -62,6 +64,7 @@ private slots:
void fboRendering();
void fboHandleNulledAfterContextDestroyed();
void openGLPaintDevice();
+ void aboutToBeDestroyed();
};
struct SharedResourceTracker
@@ -500,5 +503,24 @@ void tst_QOpenGL::openGLPaintDevice()
QCOMPARE(image, fbo.toImage().convertToFormat(QImage::Format_RGB32));
}
+void tst_QOpenGL::aboutToBeDestroyed()
+{
+ QWindow window;
+ window.setGeometry(0, 0, 128, 128);
+ window.create();
+
+ QOpenGLContext *context = new QOpenGLContext;
+ QSignalSpy spy(context, SIGNAL(aboutToBeDestroyed()));
+
+ context->create();
+ context->makeCurrent(&window);
+
+ QCOMPARE(spy.size(), 0);
+
+ delete context;
+
+ QCOMPARE(spy.size(), 1);
+}
+
QTEST_MAIN(tst_QOpenGL)
#include "tst_qopengl.moc"