tst_QOpenGL: don't leak 1399341 byte(s) [...] in 1439 allocation(s)
That's what asan reported for a run of this test executable. Create `ctx` on the stack instead of the heap to fix the leaks. For `fbo`, use a std::optional. After these fixes, the test still leaks 64 bytes in 2 allocations. These seem to be QOpenGLSharedResourceGuards in a QOpenGLFramebufferObject. Created QTBUG-134557 to track the issue. Amends - 68974d8e647febb80a47d9cf6ce9452f3ce4fa21 (fboHandleNulledAfterContextDestroyed()) - bb760d9514ed617ee8e7344152b3fa697b2c4171 (bufferMapRange()/bufferCreate()) - 0541516907da117c391b6c8d9820209673fcd9cd (vaoCreate()) Pick-to: 6.9 6.8 6.5 5.15 Task-number: QTBUG-134557 Change-Id: Icc318cd76b9f3ddf71bc294cb96d88485c42d7bc Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
75df3a250d
commit
7a1cd692e0
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QImage::Format)
|
Q_DECLARE_METATYPE(QImage::Format)
|
||||||
|
|
||||||
class tst_QOpenGL : public QObject
|
class tst_QOpenGL : public QObject
|
||||||
@ -770,7 +772,7 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
|
|||||||
window.setGeometry(0, 0, 10, 10);
|
window.setGeometry(0, 0, 10, 10);
|
||||||
window.create();
|
window.create();
|
||||||
|
|
||||||
QOpenGLFramebufferObject *fbo = 0;
|
std::optional<QOpenGLFramebufferObject> fbo;
|
||||||
|
|
||||||
{
|
{
|
||||||
QOpenGLContext ctx;
|
QOpenGLContext ctx;
|
||||||
@ -781,11 +783,12 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
|
|||||||
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
|
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
|
||||||
QSKIP("QOpenGLFramebufferObject not supported on this platform");
|
QSKIP("QOpenGLFramebufferObject not supported on this platform");
|
||||||
|
|
||||||
fbo = new QOpenGLFramebufferObject(128, 128);
|
fbo.emplace(128, 128);
|
||||||
|
|
||||||
QVERIFY(fbo->handle() != 0);
|
QVERIFY(fbo->handle() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVERIFY(fbo);
|
||||||
QCOMPARE(fbo->handle(), 0U);
|
QCOMPARE(fbo->handle(), 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1557,30 +1560,30 @@ void tst_QOpenGL::wglContextWrap()
|
|||||||
void tst_QOpenGL::vaoCreate()
|
void tst_QOpenGL::vaoCreate()
|
||||||
{
|
{
|
||||||
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
|
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
|
||||||
QOpenGLContext *ctx = new QOpenGLContext;
|
QOpenGLContext ctx;
|
||||||
ctx->create();
|
ctx.create();
|
||||||
ctx->makeCurrent(surface.data());
|
ctx.makeCurrent(surface.data());
|
||||||
|
|
||||||
QOpenGLVertexArrayObject vao;
|
QOpenGLVertexArrayObject vao;
|
||||||
bool success = vao.create();
|
bool success = vao.create();
|
||||||
if (ctx->isOpenGLES()) {
|
if (ctx.isOpenGLES()) {
|
||||||
if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object")))
|
if (ctx.format().majorVersion() >= 3 || ctx.hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object")))
|
||||||
QVERIFY(success);
|
QVERIFY(success);
|
||||||
} else {
|
} 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);
|
QVERIFY(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
vao.destroy();
|
vao.destroy();
|
||||||
ctx->doneCurrent();
|
ctx.doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QOpenGL::bufferCreate()
|
void tst_QOpenGL::bufferCreate()
|
||||||
{
|
{
|
||||||
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
|
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
|
||||||
QOpenGLContext *ctx = new QOpenGLContext;
|
QOpenGLContext ctx;
|
||||||
ctx->create();
|
ctx.create();
|
||||||
ctx->makeCurrent(surface.data());
|
ctx.makeCurrent(surface.data());
|
||||||
|
|
||||||
QOpenGLBuffer buf;
|
QOpenGLBuffer buf;
|
||||||
|
|
||||||
@ -1607,17 +1610,17 @@ void tst_QOpenGL::bufferCreate()
|
|||||||
buf.destroy();
|
buf.destroy();
|
||||||
QVERIFY(!buf.isCreated());
|
QVERIFY(!buf.isCreated());
|
||||||
|
|
||||||
ctx->doneCurrent();
|
ctx.doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QOpenGL::bufferMapRange()
|
void tst_QOpenGL::bufferMapRange()
|
||||||
{
|
{
|
||||||
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
|
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
|
||||||
QOpenGLContext *ctx = new QOpenGLContext;
|
QOpenGLContext ctx;
|
||||||
ctx->create();
|
ctx.create();
|
||||||
ctx->makeCurrent(surface.data());
|
ctx.makeCurrent(surface.data());
|
||||||
|
|
||||||
QOpenGLExtensions funcs(ctx);
|
QOpenGLExtensions funcs(&ctx);
|
||||||
if (!funcs.hasOpenGLExtension(QOpenGLExtensions::MapBufferRange))
|
if (!funcs.hasOpenGLExtension(QOpenGLExtensions::MapBufferRange))
|
||||||
QSKIP("glMapBufferRange not supported");
|
QSKIP("glMapBufferRange not supported");
|
||||||
|
|
||||||
@ -1643,7 +1646,7 @@ void tst_QOpenGL::bufferMapRange()
|
|||||||
buf.unmap();
|
buf.unmap();
|
||||||
|
|
||||||
buf.destroy();
|
buf.destroy();
|
||||||
ctx->doneCurrent();
|
ctx.doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QOpenGL::defaultQGLCurrentBuffer()
|
void tst_QOpenGL::defaultQGLCurrentBuffer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user