From 612a01be6513894ab1ec5a36b699a2142ba7f35c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 1 Nov 2020 16:53:26 +0100 Subject: Deprecate QScopedPointer::take() We've decided that QScopedPointer shouldn't be movable, because it would break the semantics of being "scoped" (the pointer/pointee won't survive the scope). Then, QScopedPointer shouldn't allow for take() either. If you need those semantics, reach for unique_ptr. [ChangeLog][QtCore][QScopedPointer] The take() function has been deprecated. This was an API mistake, as it allowed the pointer/pointee to escape from the scope, defeating the point of the QScopedPointer class. If you need such semantics, use std::unique_ptr (and call release()). Change-Id: I3236f085f763b04eb98e3242abc06f7c54fb3d8b Reviewed-by: Thiago Macieira --- src/corelib/io/qdir.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 16fd09efdb..9dd0f4ac1d 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; } -- cgit v1.2.3