From 0e92e0bd6e7209ad491472b3928840ad78c5371a Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 11 Feb 2021 16:33:46 +0100 Subject: Replace QScopedPointer with std::unique_ptr Fix compiler warning, QScopedPointer::take was deprecated in Qt 6.1. Change-Id: I67045bce97efb082b1b7467a6c24d5dbf996fdc1 Reviewed-by: Fabian Kosmale (cherry picked from commit 070072e7cabd6f4f26f4938b1616e56254ad25d9) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/particles/shared/particlestestsshared.h | 6 ++-- tests/auto/quick/qquickitem/tst_qquickitem.cpp | 6 ++-- .../tst_qquickmultipointtoucharea.cpp | 6 ++-- .../quick/qquickrepeater/tst_qquickrepeater.cpp | 36 +++++++++++----------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/auto/particles/shared/particlestestsshared.h b/tests/auto/particles/shared/particlestestsshared.h index e1fc6f4ccd..92424e98b3 100644 --- a/tests/auto/particles/shared/particlestestsshared.h +++ b/tests/auto/particles/shared/particlestestsshared.h @@ -57,18 +57,18 @@ bool myFuzzyGEQ(qreal a, qreal b) QQuickView* createView(const QUrl &filename, int additionalWait=0) { - QScopedPointer view(new QQuickView(nullptr)); + std::unique_ptr view(new QQuickView(nullptr)); view->setSource(filename); if (view->status() != QQuickView::Ready) return nullptr; view->show(); - if (!QTest::qWaitForWindowExposed(view.data())) + if (!QTest::qWaitForWindowExposed(view.get())) return nullptr; if (additionalWait) QTest::qWait(additionalWait); - return view.take(); + return view.release(); } void ensureAnimTime(int requiredTime, QAbstractAnimation* anim)//With consistentTiming, who knows how long an animation really takes... diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 61780fc405..7860f5677a 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -1986,7 +1986,7 @@ public slots: void tst_qquickitem::testSGInvalidate() { for (int i=0; i<2; ++i) { - QScopedPointer view(new QQuickView()); + std::unique_ptr view(new QQuickView()); InvalidatedItem *item = new InvalidatedItem(); @@ -2003,9 +2003,9 @@ void tst_qquickitem::testSGInvalidate() item->setParentItem(view->contentItem()); view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view.data())); + QVERIFY(QTest::qWaitForWindowExposed(view.get())); - delete view.take(); + view.reset(); QCOMPARE(invalidateSpy.size(), expected); } } diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index d70a23061b..b5ab520055 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -1177,7 +1177,7 @@ void tst_QQuickMultiPointTouchArea::transformedTouchArea() QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file) { - QScopedPointer window(new QQuickView(nullptr)); + std::unique_ptr window(new QQuickView(nullptr)); window->setSource(testFileUrl(file)); if (window->status() != QQuickView::Ready) return nullptr; @@ -1186,9 +1186,9 @@ QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file const QPoint offset = QPoint(size.width() / 2, size.height() / 2); window->setFramePosition(screenGeometry.center() - offset); window->show(); - if (!QTest::qWaitForWindowExposed(window.data())) + if (!QTest::qWaitForWindowExposed(window.get())) return nullptr; - return window.take(); + return window.release(); } void tst_QQuickMultiPointTouchArea::mouseInteraction_data() diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp index a6b0ea7059..32e4a1a05a 100644 --- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp @@ -1074,40 +1074,40 @@ void tst_QQuickRepeater::ownership() QQmlComponent component(&engine, testFileUrl("ownership.qml")); - QScopedPointer aim(new QStandardItemModel); - QPointer modelGuard(aim.data()); - QQmlEngine::setObjectOwnership(aim.data(), QQmlEngine::JavaScriptOwnership); + std::unique_ptr aim(new QStandardItemModel); + QPointer modelGuard(aim.get()); + QQmlEngine::setObjectOwnership(aim.get(), QQmlEngine::JavaScriptOwnership); { - QJSValue wrapper = engine.newQObject(aim.data()); + QJSValue wrapper = engine.newQObject(aim.get()); } - QScopedPointer repeater(component.create()); - QVERIFY(!repeater.isNull()); + std::unique_ptr repeater(component.create()); + QVERIFY(repeater); - QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(aim.data())); + QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(aim.get())); - repeater->setProperty("model", QVariant::fromValue(aim.data())); + repeater->setProperty("model", QVariant::fromValue(aim.get())); - QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(aim.data())); + QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(aim.get())); engine.collectGarbage(); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); QVERIFY(modelGuard); - QScopedPointer delegate(new QQmlComponent(&engine)); + std::unique_ptr delegate(new QQmlComponent(&engine)); delegate->setData(QByteArrayLiteral("import QtQuick 2.0\nItem{}"), dataDirectoryUrl().resolved(QUrl("inline.qml"))); - QPointer delegateGuard(delegate.data()); - QQmlEngine::setObjectOwnership(delegate.data(), QQmlEngine::JavaScriptOwnership); + QPointer delegateGuard(delegate.get()); + QQmlEngine::setObjectOwnership(delegate.get(), QQmlEngine::JavaScriptOwnership); { - QJSValue wrapper = engine.newQObject(delegate.data()); + QJSValue wrapper = engine.newQObject(delegate.get()); } - QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(delegate.data())); + QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(delegate.get())); - repeater->setProperty("delegate", QVariant::fromValue(delegate.data())); + repeater->setProperty("delegate", QVariant::fromValue(delegate.get())); - QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(delegate.data())); + QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(delegate.get())); engine.collectGarbage(); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); @@ -1120,8 +1120,8 @@ void tst_QQuickRepeater::ownership() QVERIFY(delegateGuard); QVERIFY(modelGuard); - delegate.take(); - aim.take(); + delegate.release(); + aim.release(); engine.collectGarbage(); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); -- cgit v1.2.3