summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-10-12 15:17:41 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-10-12 13:24:29 +0000
commit700b5d89a1040faba1145999e64ce31e37d5b782 (patch)
tree2e55aa92ab5548d528a75cff89d052a1ac9efddf
parentfba7e3cf5c8ad287ceaaeb381989159d8baa96ec (diff)
tst_qquickmenu: fix memory leakv5.12.0-beta2
takeItem() unparents the item, so we need to make sure it gets deleted. The leak was caught by valgrind: ==10039== 832 (32 direct, 800 indirect) bytes in 1 blocks are definitely lost in loss record 6,465 of 6,706 ==10039== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==10039== by 0x112C1E: tst_QQuickMenu::count() (tst_qquickmenu.cpp:121) ==10039== by 0x12F313: tst_QQuickMenu::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (tst_qquickmenu.moc:156) ==10039== by 0x612B6B2: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (qmetaobject.cpp:2305) ==10039== by 0x41B07CD: invoke (qmetaobject.h:123) ==10039== by 0x41B07CD: QTest::TestMethods::invokeTestOnData(int) const (qtestcase.cpp:915) ==10039== by 0x41B15BF: QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const (qtestcase.cpp:1114) ==10039== by 0x41B1D07: QTest::TestMethods::invokeTests(QObject*) const (qtestcase.cpp:1456) ==10039== by 0x41B2381: QTest::qRun() (qtestcase.cpp:1896) ==10039== by 0x41B24E1: QTest::qExec(QObject*, int, char**) (qtestcase.cpp:1783) ==10039== by 0x12F468: main (tst_qquickmenu.cpp:1505) Change-Id: I459c7897c1088c8b58152d2e0b5ceb8f3684e589 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--tests/auto/qquickmenu/tst_qquickmenu.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/auto/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp
index adb3d7aa..27cd8aaa 100644
--- a/tests/auto/qquickmenu/tst_qquickmenu.cpp
+++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp
@@ -124,7 +124,7 @@ void tst_QQuickMenu::count()
QCOMPARE(menu->count(), 1);
QCOMPARE(countSpy.count(), 3);
- QQuickItem *item = menu->takeItem(0);
+ QScopedPointer<QQuickItem> item(menu->takeItem(0));
QVERIFY(item);
QCOMPARE(menu->count(), 0);
QCOMPARE(countSpy.count(), 4);