diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 16fd09efdb6..9dd0f4ac1d5 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -63,6 +63,7 @@ #endif #include +#include #include QT_BEGIN_NAMESPACE @@ -1022,12 +1023,12 @@ bool QDir::cd(const QString &dirName) } } - QScopedPointer dir(new QDirPrivate(*d_ptr.constData())); + std::unique_ptr dir(new QDirPrivate(*d_ptr.constData())); dir->setPath(newPath); if (!dir->exists()) return false; - d_ptr = dir.take(); + d_ptr = dir.release(); return true; } @@ -1730,7 +1731,7 @@ bool QDir::isRelative() const bool QDir::makeAbsolute() { const QDirPrivate *d = d_ptr.constData(); - QScopedPointer dir; + std::unique_ptr dir; if (!!d->fileEngine) { QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); if (QDir::isRelativePath(absolutePath)) @@ -1743,7 +1744,7 @@ bool QDir::makeAbsolute() dir.reset(new QDirPrivate(*d_ptr.constData())); dir->setPath(d->absoluteDirEntry.filePath()); } - d_ptr = dir.take(); // actually detach + d_ptr = dir.release(); // actually detach return true; } diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index b0673920714..1dd77a22dc8 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -251,6 +251,8 @@ QT_BEGIN_NAMESPACE /*! \fn template T *QScopedPointer::take() + \obsolete Use std::unique_ptr and release() instead. + Returns the value of the pointer referenced by this object. The pointer of this QScopedPointer object will be reset to \nullptr. diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 5b2a15f5f6d..2297d7cb1e5 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -151,12 +151,15 @@ public: Cleanup::cleanup(oldD); } +#if QT_DEPRECATED_SINCE(6, 1) + QT_DEPRECATED_VERSION_X_6_1("Use std::unique_ptr instead, and call release().") T *take() noexcept { T *oldD = d; d = nullptr; return oldD; } +#endif void swap(QScopedPointer &other) noexcept { diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index c9da593ad28..39d2dd03542 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -40,7 +40,7 @@ #include "qdbusargument_p.h" #include "qdbusconnection.h" -#include +#include #include @@ -426,12 +426,12 @@ QDBusDemarshaller *QDBusDemarshaller::endCommon() QDBusArgument QDBusDemarshaller::duplicate() { - QScopedPointer d(new QDBusDemarshaller(capabilities)); + std::unique_ptr d(new QDBusDemarshaller(capabilities)); d->iterator = iterator; d->message = q_dbus_message_ref(message); q_dbus_message_iter_next(&iterator); - return QDBusArgumentPrivate::create(d.take()); + return QDBusArgumentPrivate::create(d.release()); } QT_END_NAMESPACE diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 585e6875e22..b7c676dd09f 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -62,6 +62,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -2554,7 +2555,7 @@ QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate() QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p) { - QScopedPointer m(new QDomNamedNodeMapPrivate(p)); + std::unique_ptr m(new QDomNamedNodeMapPrivate(p)); m->readonly = readonly; m->appendToParent = appendToParent; @@ -2567,7 +2568,7 @@ QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p) // we are no longer interested in ownership m->ref.deref(); - return m.take(); + return m.release(); } void QDomNamedNodeMapPrivate::clearMap()