Don't leak memory when tst_QOpenGL::fboTextureOwnership() fails

Hold 'fbo' in a (const) unique_ptr instead of a raw pointer, so it is
deleted even if a following QVERIFY/QCOMPARE fails.

This shows that the leak (cf. QTBUG-134557) is not due to the test
itself.

Amends dcbb16a45212d263496df1e5875da6205e4f5f53.

Pick-to: 6.8 6.5 5.15
Task-number: QTBUG-134557
Change-Id: I2f854d5ff036b7ca5e51d2e9ecb1d04bf7a39a61
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit b615c477f6472f0e3935aea05c099966c1d3ef47)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-03-10 11:00:14 +01:00 committed by Qt Cherry-pick Bot
parent b2feff382d
commit 2886996de4

View File

@ -492,7 +492,7 @@ void tst_QOpenGL::fboTextureOwnership()
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::NoAttachment);
QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(200, 100, fboFormat);
const auto fbo = std::make_unique<QOpenGLFramebufferObject>(200, 100, fboFormat);
QVERIFY(fbo->texture() != 0);
fbo->bind();
@ -516,7 +516,6 @@ void tst_QOpenGL::fboTextureOwnership()
QFUZZY_COMPARE_IMAGES(fb, reference);
ctx.functions()->glDeleteTextures(1, &texture);
delete fbo;
}
void tst_QOpenGL::fboRendering_data()