diff options
author | Amanda Hamblin-Trué <amanda.hamblin-true@qt.io> | 2023-07-28 14:00:11 +0200 |
---|---|---|
committer | Amanda Hamblin-Trué <amanda.hamblin-true@qt.io> | 2023-08-01 10:46:15 +0200 |
commit | e61da05b15524332a302009a08c27fd1a84d2983 (patch) | |
tree | eb61524397d8991bb6f83fcbb1b60d695ac670d0 /tests/auto/qml/qqmlcpputils | |
parent | f4776d4d7ec33dca2cabb60f2d33a3bf90ebc92a (diff) |
tst_qqmlcpputils: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Iffef7c7eaa8d4a9ef3f83080c666b517a925cfbb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlcpputils')
-rw-r--r-- | tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp index 11d79707d0..5fa4e9fab0 100644 --- a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp +++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp @@ -35,13 +35,11 @@ public slots: void tst_qqmlcpputils::fastConnect() { { - MyObject *obj = new MyObject; - qmlobject_connect(obj, MyObject, SIGNAL(signal1()), obj, MyObject, SLOT(slot1())); + std::unique_ptr<MyObject> obj = std::make_unique<MyObject>(); + qmlobject_connect(obj.get(), MyObject, SIGNAL(signal1()), obj.get(), MyObject, SLOT(slot1())); obj->signal1(); QCOMPARE(obj->slotCount, 1); - - delete obj; } { @@ -53,27 +51,24 @@ void tst_qqmlcpputils::fastConnect() } { - MyObject *obj = new MyObject; - QSignalSpy spy(obj, SIGNAL(signal2())); - qmlobject_connect(obj, MyObject, SIGNAL(signal1()), obj, MyObject, SIGNAL(signal2())); + std::unique_ptr<MyObject> obj = std::make_unique<MyObject>(); + QSignalSpy spy(obj.get(), SIGNAL(signal2())); + qmlobject_connect(obj.get(), MyObject, SIGNAL(signal1()), obj.get(), MyObject, SIGNAL(signal2())); obj->signal1(); QCOMPARE(spy.size(), 1); - - delete obj; } } void tst_qqmlcpputils::fastCast() { { - QObject *myObj = new MyObject; - MyObject *obj = qmlobject_cast<MyObject*>(myObj); + std::unique_ptr<QObject> myObj = std::make_unique<MyObject>(); + MyObject *obj = qmlobject_cast<MyObject*>(myObj.get()); QVERIFY(obj); QCOMPARE(obj->metaObject(), myObj->metaObject()); obj->slot1(); QCOMPARE(obj->slotCount, 1); - delete myObj; } { |