From 2fb2b238de9e4894f78f26da6eafcc90b08741f9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 20 Sep 2023 22:56:46 -0700 Subject: [PATCH] moveToTrash/Unix: remove unnecessary targetPath variable It was used twice, in both cases to create a QFileSystemEntry, so the two results were equal. Therefore, just use the first result to create the second. Change-Id: I9d43e5b91eb142d6945cfffd1786d45d20485f40 Reviewed-by: Volker Hilsheimer (cherry picked from commit 3d027f8d959879d0c0525fedd03907a607ea32ee) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/io/qfilesystemengine_unix.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index ef73b8c88f0..4b9e94df0f8 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1361,9 +1361,6 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, uniqueTrashedName = makeUniqueTrashedName(); } while (!infoFile.isOpen()); - const QString targetPath = trashDir.filePath(filesDir) + uniqueTrashedName; - const QFileSystemEntry target(targetPath); - QString pathForInfo; const QStorageInfo storageInfo(sourcePath); if (storageInfo.isValid() && storageInfo.rootPath() != rootPath() && storageInfo != QStorageInfo(QDir::home())) { @@ -1379,6 +1376,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, In that case, we don't try further, i.e. copying and removing the original is usually not what the user would expect to happen. */ + QFileSystemEntry target(trashDir.filePath(filesDir) + uniqueTrashedName); if (!renameFile(source, target, error)) { infoFile.close(); infoFile.remove(); @@ -1393,7 +1391,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, infoFile.write(info); infoFile.close(); - newLocation = QFileSystemEntry(targetPath); + newLocation = std::move(target); return true; #endif // QT_BOOTSTRAPPED }