diff options
Diffstat (limited to 'tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp')
-rw-r--r-- | tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp index 11d79707d0..d858fd2ff0 100644 --- a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp +++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <qtest.h> #include <qsignalspy.h> @@ -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; } { |