summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 3f4aa8cd8f9..4cc2dc49027 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -29,6 +29,8 @@
#include <QSignalSpy>
+#include <optional>
+
Q_DECLARE_METATYPE(QImage::Format)
class tst_QOpenGL : public QObject
@@ -770,7 +772,7 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
window.setGeometry(0, 0, 10, 10);
window.create();
- QOpenGLFramebufferObject *fbo = 0;
+ std::optional<QOpenGLFramebufferObject> fbo;
{
QOpenGLContext ctx;
@@ -781,11 +783,12 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
- fbo = new QOpenGLFramebufferObject(128, 128);
+ fbo.emplace(128, 128);
QVERIFY(fbo->handle() != 0);
}
+ QVERIFY(fbo);
QCOMPARE(fbo->handle(), 0U);
}
@@ -1557,30 +1560,30 @@ void tst_QOpenGL::wglContextWrap()
void tst_QOpenGL::vaoCreate()
{
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
- QOpenGLContext *ctx = new QOpenGLContext;
- ctx->create();
- ctx->makeCurrent(surface.data());
+ QOpenGLContext ctx;
+ ctx.create();
+ ctx.makeCurrent(surface.data());
QOpenGLVertexArrayObject vao;
bool success = vao.create();
- if (ctx->isOpenGLES()) {
- if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object")))
+ if (ctx.isOpenGLES()) {
+ if (ctx.format().majorVersion() >= 3 || ctx.hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object")))
QVERIFY(success);
} else {
- if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object")))
+ if (ctx.format().majorVersion() >= 3 || ctx.hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object")))
QVERIFY(success);
}
vao.destroy();
- ctx->doneCurrent();
+ ctx.doneCurrent();
}
void tst_QOpenGL::bufferCreate()
{
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
- QOpenGLContext *ctx = new QOpenGLContext;
- ctx->create();
- ctx->makeCurrent(surface.data());
+ QOpenGLContext ctx;
+ ctx.create();
+ ctx.makeCurrent(surface.data());
QOpenGLBuffer buf;
@@ -1607,17 +1610,17 @@ void tst_QOpenGL::bufferCreate()
buf.destroy();
QVERIFY(!buf.isCreated());
- ctx->doneCurrent();
+ ctx.doneCurrent();
}
void tst_QOpenGL::bufferMapRange()
{
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
- QOpenGLContext *ctx = new QOpenGLContext;
- ctx->create();
- ctx->makeCurrent(surface.data());
+ QOpenGLContext ctx;
+ ctx.create();
+ ctx.makeCurrent(surface.data());
- QOpenGLExtensions funcs(ctx);
+ QOpenGLExtensions funcs(&ctx);
if (!funcs.hasOpenGLExtension(QOpenGLExtensions::MapBufferRange))
QSKIP("glMapBufferRange not supported");
@@ -1643,7 +1646,7 @@ void tst_QOpenGL::bufferMapRange()
buf.unmap();
buf.destroy();
- ctx->doneCurrent();
+ ctx.doneCurrent();
}
void tst_QOpenGL::defaultQGLCurrentBuffer()