From a5b4a8dbaa2f6535fa659fb95b75c059a04c6235 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 15 Mar 2019 11:11:45 +0100 Subject: Fix some memory leaks Use QScopedPointer where appropriate to avoid reporting false memory leaks with ASAN's leak checker. Change-Id: Ia3dfeafc66c2ad2ac8454861acce82b99678e517 Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index a862604fc1..4cf7fa7119 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1645,11 +1645,11 @@ void tst_qquickwindow::focusReason() window->setTitle(QTest::currentTestFunction()); QVERIFY(QTest::qWaitForWindowExposed(window)); - QQuickItem *firstItem = new QQuickItem; + QScopedPointer firstItem(new QQuickItem); firstItem->setSize(QSizeF(100, 100)); firstItem->setParentItem(window->contentItem()); - QQuickItem *secondItem = new QQuickItem; + QScopedPointer secondItem(new QQuickItem); secondItem->setSize(QSizeF(100, 100)); secondItem->setParentItem(window->contentItem()); @@ -1673,7 +1673,7 @@ void tst_qquickwindow::ignoreUnhandledMouseEvents() window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); - QQuickItem *item = new QQuickItem; + QScopedPointer item(new QQuickItem); item->setSize(QSizeF(100, 100)); item->setParentItem(window->contentItem()); @@ -1883,8 +1883,8 @@ void tst_qquickwindow::hideThenDelete() QFETCH(bool, persistentSG); QFETCH(bool, persistentGL); - QSignalSpy *openglDestroyed = nullptr; - QSignalSpy *sgInvalidated = nullptr; + QScopedPointer openglDestroyed; + QScopedPointer sgInvalidated; { QQuickWindow window; @@ -1903,10 +1903,10 @@ void tst_qquickwindow::hideThenDelete() const bool isGL = window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; #if QT_CONFIG(opengl) if (isGL) - openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed())); + openglDestroyed.reset(new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed()))); #endif - sgInvalidated = new QSignalSpy(&window, SIGNAL(sceneGraphInvalidated())); + sgInvalidated.reset(new QSignalSpy(&window, SIGNAL(sceneGraphInvalidated()))); window.hide(); @@ -1951,7 +1951,7 @@ void tst_qquickwindow::showHideAnimate() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("showHideAnimate.qml")); - QQuickItem* created = qobject_cast(component.create()); + QScopedPointer created(qobject_cast(component.create())); QVERIFY(created); @@ -2293,7 +2293,7 @@ void tst_qquickwindow::contentItemSize() QQmlEngine engine; QQmlComponent component(&engine); component.setData(QByteArray("import QtQuick 2.1\n Rectangle { anchors.fill: parent }"), QUrl()); - QQuickItem *rect = qobject_cast(component.create()); + QScopedPointer rect(qobject_cast(component.create())); QVERIFY(rect); rect->setParentItem(window.contentItem()); QCOMPARE(QSizeF(rect->width(), rect->height()), size); -- cgit v1.2.3