summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-06 16:36:37 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-19 17:54:19 +0200
commit40c571cd727cf0eb8523dc063030fa6cad57c8a3 (patch)
tree941b846682cf2d6bd5ee5727cd4345bf80f65264 /src/corelib/io
parent8696a2eb073217516c7c4c22437d2e59868e4440 (diff)
QFile::moveToTrash: work with relative file paths on Windows
The system APIs expect an absolute "display name" of the file path, so make it absolute. The test was overly tolerant in accepting failure, as a QStorageInfo initialized with a file path that doesn't exist is invalid, and thus always different from the QStorageInfo of the home directory. Fix the test to compare only valid QStorageInfo objects, and postpone the check until the file we want to move has been created. [ChangeLog][QtCore][QFile] moveToTrash supports relative file paths on Windows Change-Id: I94c8cd40c60fde469e38f76a98f867f20c6a0b15 Fixes: QTBUG-84015 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> (cherry picked from commit a033c23ddffed6b9bff3e7be68d513a7962c3b5e) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 6ad123f3b6..54a0d07165 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -1543,8 +1543,8 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
QFileSystemEntry &newLocation, QSystemError &error)
{
#ifndef Q_OS_WINRT
- // we need the "display name" of the file, so can't use nativeFilePath
- const QString sourcePath = QDir::toNativeSeparators(source.filePath());
+ // we need the "display name" of the file, so can't use nativeAbsoluteFilePath
+ const QString sourcePath = QDir::toNativeSeparators(absoluteName(source).filePath());
/*
Windows 7 insists on showing confirmation dialogs and ignores the respective