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 <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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user