diff --git a/src/qtpromise/qpromise_p.h b/src/qtpromise/qpromise_p.h index 71aa894..a4ff3ce 100644 --- a/src/qtpromise/qpromise_p.h +++ b/src/qtpromise/qpromise_p.h @@ -81,8 +81,8 @@ class PromiseValue { public: PromiseValue() { } - PromiseValue(const T& data) : m_data(new T(data)) { } - PromiseValue(T&& data) : m_data(new T(std::move(data))) { } + PromiseValue(const T& data) : m_data(QSharedPointer::create(data)) { } + PromiseValue(T&& data) : m_data(QSharedPointer::create(std::forward(data))) { } bool isNull() const { return m_data.isNull(); } const T& data() const { return *m_data; } diff --git a/src/qtpromise/qpromiseconnections.h b/src/qtpromise/qpromiseconnections.h index b9ceab6..ecc7510 100644 --- a/src/qtpromise/qpromiseconnections.h +++ b/src/qtpromise/qpromiseconnections.h @@ -15,7 +15,7 @@ namespace QtPromise { class QPromiseConnections { public: - QPromiseConnections() : m_d(new Data()) { } + QPromiseConnections() : m_d(QSharedPointer::create()) { } int count() const { return m_d->connections.count(); } diff --git a/src/qtpromise/qpromisehelpers.h b/src/qtpromise/qpromisehelpers.h index 95162bc..46d18a9 100644 --- a/src/qtpromise/qpromisehelpers.h +++ b/src/qtpromise/qpromisehelpers.h @@ -59,8 +59,8 @@ all(const Sequence, Args...>& promises) const QPromiseResolve>& resolve, const QPromiseReject>& reject) { - QSharedPointer remaining(new int(count)); - QSharedPointer> results(new QVector(count)); + auto remaining = QSharedPointer::create(count); + auto results = QSharedPointer>::create(count); int i = 0; for (const auto& promise: promises) { @@ -94,7 +94,7 @@ all(const Sequence, Args...>& promises) const QPromiseResolve& resolve, const QPromiseReject& reject) { - QSharedPointer remaining(new int(count)); + auto remaining = QSharedPointer::create(count); for (const auto& promise: promises) { promise.then([=]() { diff --git a/tests/auto/qtpromise/deprecations/tst_helpers_qpromise.cpp b/tests/auto/qtpromise/deprecations/tst_helpers_qpromise.cpp index e5a7123..189e7ba 100644 --- a/tests/auto/qtpromise/deprecations/tst_helpers_qpromise.cpp +++ b/tests/auto/qtpromise/deprecations/tst_helpers_qpromise.cpp @@ -108,10 +108,10 @@ void tst_deprecations_helpers_qpromise::qtSharedPtr() QWeakPointer wptr; { - QSharedPointer sptr0(new Data(42)); + auto sptr0 = QSharedPointer::create(42); const QSharedPointer sptr1 = sptr0; - auto p0 = qPromise(QSharedPointer(new Data(42))); + auto p0 = qPromise(QSharedPointer::create(42)); auto p1 = qPromise(sptr0); auto p2 = qPromise(sptr1); @@ -144,10 +144,10 @@ void tst_deprecations_helpers_qpromise::stdSharedPtr() std::weak_ptr wptr; { - std::shared_ptr sptr0(new Data(42)); + auto sptr0 = std::make_shared(42); const std::shared_ptr sptr1 = sptr0; - auto p0 = qPromise(std::shared_ptr(new Data(42))); + auto p0 = qPromise(std::make_shared(42)); auto p1 = qPromise(sptr0); auto p2 = qPromise(sptr1); diff --git a/tests/auto/qtpromise/helpers/tst_reject.cpp b/tests/auto/qtpromise/helpers/tst_reject.cpp index dd9e3a7..e7bc169 100644 --- a/tests/auto/qtpromise/helpers/tst_reject.cpp +++ b/tests/auto/qtpromise/helpers/tst_reject.cpp @@ -41,7 +41,7 @@ void tst_helpers_reject::rejectWithQSharedPtr() QWeakPointer wptr; { - QSharedPointer sptr(new int(42)); + auto sptr = QSharedPointer::create(42); auto p = QPromise::reject(sptr); QCOMPARE(waitForError(p, QSharedPointer()), sptr); @@ -61,7 +61,7 @@ void tst_helpers_reject::rejectWithStdSharedPtr() std::weak_ptr wptr; { - std::shared_ptr sptr(new int(42)); + auto sptr = std::make_shared(42); auto p = QPromise::reject(sptr); QCOMPARE(waitForError(p, std::shared_ptr()), sptr); diff --git a/tests/auto/qtpromise/helpers/tst_resolve.cpp b/tests/auto/qtpromise/helpers/tst_resolve.cpp index 52cbb86..d9bb7b7 100644 --- a/tests/auto/qtpromise/helpers/tst_resolve.cpp +++ b/tests/auto/qtpromise/helpers/tst_resolve.cpp @@ -108,10 +108,10 @@ void tst_helpers_resolve::qtSharedPtr() QWeakPointer wptr; { - QSharedPointer sptr0(new Data(42)); + auto sptr0 = QSharedPointer::create(42); const QSharedPointer sptr1 = sptr0; - auto p0 = QtPromise::resolve(QSharedPointer(new Data(42))); + auto p0 = QtPromise::resolve(QSharedPointer::create(42)); auto p1 = QtPromise::resolve(sptr0); auto p2 = QtPromise::resolve(sptr1); @@ -144,10 +144,10 @@ void tst_helpers_resolve::stdSharedPtr() std::weak_ptr wptr; { - std::shared_ptr sptr0(new Data(42)); + auto sptr0 = std::make_shared(42); const std::shared_ptr sptr1 = sptr0; - auto p0 = QtPromise::resolve(std::shared_ptr(new Data(42))); + auto p0 = QtPromise::resolve(std::make_shared(42)); auto p1 = QtPromise::resolve(sptr0); auto p2 = QtPromise::resolve(sptr1); diff --git a/tests/auto/qtpromise/qpromise/tst_construct.cpp b/tests/auto/qtpromise/qpromise/tst_construct.cpp index c108aab..e6a2e98 100644 --- a/tests/auto/qtpromise/qpromise/tst_construct.cpp +++ b/tests/auto/qtpromise/qpromise/tst_construct.cpp @@ -276,7 +276,7 @@ void tst_qpromise_construct::connectAndResolve() connect(object.data(), &QObject::objectNameChanged, [=, &wptr](const QString& name) { - std::shared_ptr sptr(new int(42)); + auto sptr = std::make_shared(42); wptr = sptr; @@ -313,7 +313,7 @@ void tst_qpromise_construct::connectAndReject() connect(object.data(), &QObject::objectNameChanged, [=, &wptr](const QString& name) { - std::shared_ptr sptr(new int(42)); + auto sptr = std::make_shared(42); wptr = sptr; diff --git a/tests/auto/qtpromise/qpromise/tst_resolve.cpp b/tests/auto/qtpromise/qpromise/tst_resolve.cpp index 362e8b2..178c855 100644 --- a/tests/auto/qtpromise/qpromise/tst_resolve.cpp +++ b/tests/auto/qtpromise/qpromise/tst_resolve.cpp @@ -103,10 +103,10 @@ void tst_qpromise_resolve::qtSharedPtr() QWeakPointer wptr; { - QSharedPointer sptr0(new Data(42)); + auto sptr0 = QSharedPointer::create(42); const QSharedPointer sptr1 = sptr0; - auto p0 = QPromise>::resolve(QSharedPointer(new Data(42))); + auto p0 = QPromise>::resolve(QSharedPointer::create(42)); auto p1 = QPromise>::resolve(sptr0); auto p2 = QPromise>::resolve(sptr1); @@ -139,10 +139,10 @@ void tst_qpromise_resolve::stdSharedPtr() std::weak_ptr wptr; { - std::shared_ptr sptr0(new Data(42)); + auto sptr0 = std::make_shared(42); const std::shared_ptr sptr1 = sptr0; - auto p0 = QPromise>::resolve(std::shared_ptr(new Data(42))); + auto p0 = QPromise>::resolve(std::make_shared(42)); auto p1 = QPromise>::resolve(sptr0); auto p2 = QPromise>::resolve(sptr1);