summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-02-07 09:37:10 -0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-15 22:25:46 +0000
commitcffe6800d1db6ef810715d884ee20c07e388fef9 (patch)
tree0e719db27196167449a3be36dc1118010f685b38 /src/corelib
parent8bb9290b72b379c9af6ae99b9f9b66235fd99675 (diff)
downloadqtbase-cffe6800d1db6ef810715d884ee20c07e388fef9.tar.gz
QFileSystemWatcher/Win: remove the pre-QFileInfo path normalization
It's completely unnecessary, since QFileInfo will query the file system anyway and that has a much better view of what is normalized and what isn't. More importantly, this fixes the mistake in failing to normalize properly in removePaths(), which removed the ending slash of a root directory such as "C:\\". That caused the path to become "C:", which QFileInfo interprets as "current path on drive C:". [ChangeLog][QtCore][QFileSystemWatcher] Fixed a bug that prevented removePaths() from removing the root of a drive on Windows. Fixes: QTBUG-110986 Change-Id: I9671dee8ceb64aa9b9cafffd17419b6d69670876 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 6d1769791348e9387e0c5f29d970131895888814) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 7586054c27..a0b2b006d6 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -332,12 +332,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QStringList unhandled;
for (const QString &path : paths) {
auto sg = qScopeGuard([&] { unhandled.push_back(path); });
- QString normalPath = path;
- if ((normalPath.endsWith(u'/') && !normalPath.endsWith(":/"_L1))
- || (normalPath.endsWith(u'\\') && !normalPath.endsWith(":\\"_L1))) {
- normalPath.chop(1);
- }
- QFileInfo fileInfo(normalPath);
+ QFileInfo fileInfo(path);
fileInfo.stat();
if (!fileInfo.exists())
continue;
@@ -351,7 +346,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
continue;
}
- DEBUG() << "Looking for a thread/handle for" << normalPath;
+ DEBUG() << "Looking for a thread/handle for" << fileInfo.path();
const QString absolutePath = isDir ? fileInfo.absoluteFilePath() : fileInfo.absolutePath();
const uint flags = isDir
@@ -495,11 +490,8 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path
QStringList unhandled;
for (const QString &path : paths) {
auto sg = qScopeGuard([&] { unhandled.push_back(path); });
- QString normalPath = path;
- if (normalPath.endsWith(u'/') || normalPath.endsWith(u'\\'))
- normalPath.chop(1);
- QFileInfo fileInfo(normalPath);
- DEBUG() << "removing" << normalPath;
+ QFileInfo fileInfo(path);
+ DEBUG() << "removing" << fileInfo.path();
QString absolutePath = fileInfo.absoluteFilePath();
QList<QWindowsFileSystemWatcherEngineThread *>::iterator jt, end;
end = threads.end();