From f6eb570c7dee2ec92383607c614db91f31804707 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 29 Sep 2016 11:59:01 +0200 Subject: Darwin: normalize all watched paths to composed from MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will be done by all POSIX APIs for strings coming in that way, but because other code (like NSWhateverViews) will most likely return decomposed form, we make sure that those are in composed form too. Task-number: QTBUG-55896 Change-Id: I065e11cee6b59706d4346ed20d4b59b9b95163b8 Reviewed-by: Morten Johan Sørvig --- src/corelib/io/qfilesystemwatcher_fsevents.mm | 2 +- .../qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index c6fa6c9846..6af9e5f5ef 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -343,7 +343,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList p = paths; QMutableListIterator it(p); while (it.hasNext()) { - QString origPath = it.next(); + QString origPath = it.next().normalized(QString::NormalizationForm_C); QString realPath = origPath; if (realPath.endsWith(QDir::separator())) realPath = realPath.mid(0, realPath.size() - 1); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 026743257c..4ede1e69f3 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -78,6 +78,8 @@ private slots: void signalsEmittedAfterFileMoved(); + void watchUnicodeCharacters(); + private: QString m_tempDirPattern; #endif // QT_NO_FILESYSTEMWATCHER @@ -763,6 +765,25 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved() QVERIFY2(changedSpy.count() <= fileCount, changedSpy.receivedFilesMessage()); QTRY_COMPARE(changedSpy.count(), fileCount); } + +void tst_QFileSystemWatcher::watchUnicodeCharacters() +{ + QTemporaryDir temporaryDirectory(m_tempDirPattern); + QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString())); + + QDir testDir(temporaryDirectory.path()); + const QString subDir(QString::fromLatin1("caf\xe9")); + QVERIFY(testDir.mkdir(subDir)); + testDir = QDir(temporaryDirectory.path() + QDir::separator() + subDir); + + QFileSystemWatcher watcher; + QVERIFY(watcher.addPath(testDir.path())); + + FileSystemWatcherSpy changedSpy(&watcher, FileSystemWatcherSpy::SpyOnDirectoryChanged); + QCOMPARE(changedSpy.count(), 0); + QVERIFY(testDir.mkdir("creme")); + QTRY_COMPARE(changedSpy.count(), 1); +} #endif // QT_NO_FILESYSTEMWATCHER QTEST_MAIN(tst_QFileSystemWatcher) -- cgit v1.2.3