Details
-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
None
-
4.8.2
-
None
Description
In the following test case, the watchFiles() function will often hang when invoked on Windows as the QFileSystemWatcher::fileChanged() notification is not always emitted, though the file is modified after the watcher is created. I was not able to reproduce the problem on Mac or Linux.
void writeRandomDataToFile(const QString& path) { QFile file(path); file.open(QIODevice::WriteOnly); QByteArray data; for (int i=0; i < 50; i++) { data.append(qrand()); } file.write(data); file.close(); } void watchFiles() { QString testPath = "test-path.txt"; writeRandomDataToFile(testPath); for (int i=0; i < 100; i++) { QFileSystemWatcher watcher; QSignalSpy spy(&watcher, SIGNAL(fileChanged(QString))); watcher.addPath(testPath); writeRandomDataToFile(testPath); while (spy.isEmpty()) { QCoreApplication::processEvents(); } } }