25QStringList QPollingFileSystemWatcherEngine::addPaths(
const QStringList &paths,
27 QStringList *directories)
29 QStringList unhandled;
30 for (
const QString &path : paths) {
31 auto sg = qScopeGuard([&]{ unhandled.push_back(path); });
36 if (directories->contains(path))
38 directories->append(path);
39 if (!path.endsWith(u'/'))
40 fi = QFileInfo(path + u'/');
41 this->directories.insert(path, fi);
43 if (files->contains(path))
46 this->files.insert(path, fi);
51 std::chrono::milliseconds interval = PollingInterval;
52#ifdef QT_BUILD_INTERNAL
53 if (Q_UNLIKELY(parent()->objectName().startsWith(
"_qt_autotest_force_engine_"_L1))) {
58 if ((!
this->files.isEmpty() ||
59 !
this->directories.isEmpty()) &&
61 timer.start(interval,
this);
67QStringList QPollingFileSystemWatcherEngine::removePaths(
const QStringList &paths,
69 QStringList *directories)
71 QStringList unhandled;
72 for (
const QString &path : paths) {
73 if (
this->directories.remove(path)) {
74 directories->removeAll(path);
75 }
else if (
this->files.remove(path)) {
76 files->removeAll(path);
78 unhandled.push_back(path);
82 if (
this->files.isEmpty() &&
83 this->directories.isEmpty()) {
90void QPollingFileSystemWatcherEngine::timerEvent(QTimerEvent *e)
92 if (e->id() != timer.id())
93 return QFileSystemWatcherEngine::timerEvent(e);
95 for (
auto it = files.begin(), end = files.end(); it != end; ) {
96 QString path = it.key();
100 emit fileChanged(path,
true);
102 }
else if (it.value() != fi) {
104 emit fileChanged(path,
false);
109 for (
auto it = directories.begin(), end = directories.end(); it != end; ) {
110 QString path = it.key();
112 if (!path.endsWith(u'/'))
113 fi = QFileInfo(path + u'/');
115 it = directories.erase(it);
116 emit directoryChanged(path,
true);
118 }
else if (it.value() != fi) {
121 it = directories.erase(it);
122 emit directoryChanged(path,
true);
126 emit directoryChanged(path,
false);