From 2886996de4f0359a1f44cc24aa55c81a3b008aa1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Mar 2025 11:00:14 +0100 Subject: [PATCH] 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 (cherry picked from commit b615c477f6472f0e3935aea05c099966c1d3ef47) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/gui/qopengl/tst_qopengl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 4cc2dc49027..36ff1d1f2e9 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -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(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()