io/qfilesystemwatcher.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13 -
14 -
15 -
16 -
17 -
18QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent) -
19{ -
20 -
21 -
22 -
23 -
24 -
25 return QInotifyFileSystemWatcherEngine::create(parent);
executed: return QInotifyFileSystemWatcherEngine::create(parent);
Execution Count:289
289
26 -
27 -
28 -
29 -
30 -
31} -
32 -
33QFileSystemWatcherPrivate::QFileSystemWatcherPrivate() -
34 : native(0), poller(0) -
35{ -
36}
executed: }
Execution Count:289
289
37 -
38void QFileSystemWatcherPrivate::init() -
39{ -
40 QFileSystemWatcher * const q = q_func(); -
41 native = createNativeEngine(q); -
42 if (native) {
partially evaluated: native
TRUEFALSE
yes
Evaluation Count:289
no
Evaluation Count:0
0-289
43 QObject::connect(native, -
44 "2""fileChanged(QString,bool)", -
45 q, -
46 "1""_q_fileChanged(QString,bool)"); -
47 QObject::connect(native, -
48 "2""directoryChanged(QString,bool)", -
49 q, -
50 "1""_q_directoryChanged(QString,bool)"); -
51 }
executed: }
Execution Count:289
289
52}
executed: }
Execution Count:289
289
53 -
54void QFileSystemWatcherPrivate::initPollerEngine() -
55{ -
56 if(poller)
evaluated: poller
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-5
57 return;
executed: return;
Execution Count:5
5
58 -
59 QFileSystemWatcher * const q = q_func(); -
60 poller = new QPollingFileSystemWatcherEngine(q); -
61 QObject::connect(poller, -
62 "2""fileChanged(QString,bool)", -
63 q, -
64 "1""_q_fileChanged(QString,bool)"); -
65 QObject::connect(poller, -
66 "2""directoryChanged(QString,bool)", -
67 q, -
68 "1""_q_directoryChanged(QString,bool)"); -
69}
executed: }
Execution Count:4
4
70 -
71void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed) -
72{ -
73 QFileSystemWatcher * const q = q_func(); -
74 if (!files.contains(path)) {
partially evaluated: !files.contains(path)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
75 -
76 return;
never executed: return;
0
77 } -
78 if (removed)
evaluated: removed
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
4-8
79 files.removeAll(path);
executed: files.removeAll(path);
Execution Count:4
4
80 q->fileChanged(path, QFileSystemWatcher::QPrivateSignal()); -
81}
executed: }
Execution Count:12
12
82 -
83void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed) -
84{ -
85 QFileSystemWatcher * const q = q_func(); -
86 if (!directories.contains(path)) {
partially evaluated: !directories.contains(path)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
0-55
87 -
88 return;
never executed: return;
0
89 } -
90 if (removed)
evaluated: removed
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:51
4-51
91 directories.removeAll(path);
executed: directories.removeAll(path);
Execution Count:4
4
92 q->directoryChanged(path, QFileSystemWatcher::QPrivateSignal()); -
93}
executed: }
Execution Count:55
55
94QFileSystemWatcher::QFileSystemWatcher(QObject *parent) -
95 : QObject(*new QFileSystemWatcherPrivate, parent) -
96{ -
97 d_func()->init(); -
98}
executed: }
Execution Count:289
289
99 -
100 -
101 -
102 -
103 -
104QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent) -
105 : QObject(*new QFileSystemWatcherPrivate, parent) -
106{ -
107 d_func()->init(); -
108 addPaths(paths); -
109}
never executed: }
0
110 -
111 -
112 -
113 -
114QFileSystemWatcher::~QFileSystemWatcher() -
115{ } -
116bool QFileSystemWatcher::addPath(const QString &path) -
117{ -
118 if (path.isEmpty()) {
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:324
1-324
119 QMessageLogger("io/qfilesystemwatcher.cpp", 251, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::addPath: path is empty"); -
120 return true;
executed: return true;
Execution Count:1
1
121 } -
122 -
123 QStringList paths = addPaths(QStringList(path)); -
124 return paths.isEmpty();
executed: return paths.isEmpty();
Execution Count:324
324
125} -
126QStringList QFileSystemWatcher::addPaths(const QStringList &paths) -
127{ -
128 QFileSystemWatcherPrivate * const d = d_func(); -
129 -
130 QStringList p = paths; -
131 QMutableListIterator<QString> it(p); -
132 -
133 while (it.hasNext()) {
evaluated: it.hasNext()
TRUEFALSE
yes
Evaluation Count:330
yes
Evaluation Count:329
329-330
134 const QString &path = it.next(); -
135 if (path.isEmpty())
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:329
1-329
136 it.remove();
executed: it.remove();
Execution Count:1
1
137 }
executed: }
Execution Count:330
330
138 -
139 if (p.isEmpty()) {
evaluated: p.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:327
2-327
140 QMessageLogger("io/qfilesystemwatcher.cpp", 296, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::addPaths: list is empty"); -
141 return QStringList();
executed: return QStringList();
Execution Count:2
2
142 } -
143 -
144 QFileSystemWatcherEngine *engine = 0; -
145 -
146 if(!objectName().startsWith(QLatin1String("_qt_autotest_force_engine_"))) {
evaluated: !objectName().startsWith(QLatin1String("_qt_autotest_force_engine_"))
TRUEFALSE
yes
Evaluation Count:309
yes
Evaluation Count:18
18-309
147 -
148 if(d->native) {
partially evaluated: d->native
TRUEFALSE
yes
Evaluation Count:309
no
Evaluation Count:0
0-309
149 engine = d->native; -
150 } else {
executed: }
Execution Count:309
309
151 d_func()->initPollerEngine(); -
152 engine = d->poller; -
153 }
never executed: }
0
154 -
155 } else { -
156 -
157 QString forceName = objectName().mid(26); -
158 if(forceName == QLatin1String("poller")) {
evaluated: forceName == QLatin1String("poller")
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:9
9
159 QMessageLogger("io/qfilesystemwatcher.cpp", 315, __PRETTY_FUNCTION__).debug() << "QFileSystemWatcher: skipping native engine, using only polling engine"; -
160 d_func()->initPollerEngine(); -
161 engine = d->poller; -
162 } else if(forceName == QLatin1String("native")) {
executed: }
Execution Count:9
partially evaluated: forceName == QLatin1String("native")
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
163 QMessageLogger("io/qfilesystemwatcher.cpp", 319, __PRETTY_FUNCTION__).debug() << "QFileSystemWatcher: skipping polling engine, using only native engine"; -
164 engine = d->native; -
165 }
executed: }
Execution Count:9
9
166 } -
167 -
168 if(engine)
partially evaluated: engine
TRUEFALSE
yes
Evaluation Count:327
no
Evaluation Count:0
0-327
169 p = engine->addPaths(p, &d->files, &d->directories);
executed: p = engine->addPaths(p, &d->files, &d->directories);
Execution Count:327
327
170 -
171 return p;
executed: return p;
Execution Count:327
327
172} -
173bool QFileSystemWatcher::removePath(const QString &path) -
174{ -
175 if (path.isEmpty()) {
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:65
1-65
176 QMessageLogger("io/qfilesystemwatcher.cpp", 343, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::removePath: path is empty"); -
177 return true;
executed: return true;
Execution Count:1
1
178 } -
179 -
180 QStringList paths = removePaths(QStringList(path)); -
181 return paths.isEmpty();
executed: return paths.isEmpty();
Execution Count:65
65
182} -
183QStringList QFileSystemWatcher::removePaths(const QStringList &paths) -
184{ -
185 QFileSystemWatcherPrivate * const d = d_func(); -
186 -
187 QStringList p = paths; -
188 QMutableListIterator<QString> it(p); -
189 -
190 while (it.hasNext()) {
evaluated: it.hasNext()
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:68
68
191 const QString &path = it.next(); -
192 if (path.isEmpty())
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:67
1-67
193 it.remove();
executed: it.remove();
Execution Count:1
1
194 }
executed: }
Execution Count:68
68
195 -
196 if (p.isEmpty()) {
evaluated: p.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:66
2-66
197 QMessageLogger("io/qfilesystemwatcher.cpp", 376, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::removePaths: list is empty"); -
198 return QStringList();
executed: return QStringList();
Execution Count:2
2
199 } -
200 -
201 if (d->native)
partially evaluated: d->native
TRUEFALSE
yes
Evaluation Count:66
no
Evaluation Count:0
0-66
202 p = d->native->removePaths(p, &d->files, &d->directories);
executed: p = d->native->removePaths(p, &d->files, &d->directories);
Execution Count:66
66
203 if (d->poller)
evaluated: d->poller
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:61
5-61
204 p = d->poller->removePaths(p, &d->files, &d->directories);
executed: p = d->poller->removePaths(p, &d->files, &d->directories);
Execution Count:5
5
205 -
206 return p;
executed: return p;
Execution Count:66
66
207} -
208QStringList QFileSystemWatcher::directories() const -
209{ -
210 const QFileSystemWatcherPrivate * const d = d_func(); -
211 return d->directories;
executed: return d->directories;
Execution Count:352
352
212} -
213 -
214QStringList QFileSystemWatcher::files() const -
215{ -
216 const QFileSystemWatcherPrivate * const d = d_func(); -
217 return d->files;
never executed: return d->files;
0
218} -
219 -
220 -
221 -
222 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial