OpenCoverage

qfilesystemwatcher_inotify.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qfilesystemwatcher.h"-
41#include "qfilesystemwatcher_inotify_p.h"-
42-
43#ifndef QT_NO_FILESYSTEMWATCHER-
44-
45#include "private/qcore_unix_p.h"-
46#include "private/qsystemerror_p.h"-
47-
48#include <qdebug.h>-
49#include <qfile.h>-
50#include <qfileinfo.h>-
51#include <qsocketnotifier.h>-
52#include <qvarlengtharray.h>-
53-
54#if defined(Q_OS_LINUX)-
55#include <sys/syscall.h>-
56#include <sys/ioctl.h>-
57#include <unistd.h>-
58#include <fcntl.h>-
59#endif-
60-
61#if defined(QT_NO_INOTIFY)-
62-
63#if defined(Q_OS_QNX)-
64// These files should only be compiled on QNX if the inotify headers are found-
65#error "Should not get here."-
66#endif-
67-
68#include <linux/types.h>-
69-
70#if defined(__i386__)-
71# define __NR_inotify_init 291-
72# define __NR_inotify_add_watch 292-
73# define __NR_inotify_rm_watch 293-
74# define __NR_inotify_init1 332-
75#elif defined(__x86_64__)-
76# define __NR_inotify_init 253-
77# define __NR_inotify_add_watch 254-
78# define __NR_inotify_rm_watch 255-
79# define __NR_inotify_init1 294-
80#elif defined(__powerpc__) || defined(__powerpc64__)-
81# define __NR_inotify_init 275-
82# define __NR_inotify_add_watch 276-
83# define __NR_inotify_rm_watch 277-
84# define __NR_inotify_init1 318-
85#elif defined (__ia64__)-
86# define __NR_inotify_init 1277-
87# define __NR_inotify_add_watch 1278-
88# define __NR_inotify_rm_watch 1279-
89# define __NR_inotify_init1 1318-
90#elif defined (__s390__) || defined (__s390x__)-
91# define __NR_inotify_init 284-
92# define __NR_inotify_add_watch 285-
93# define __NR_inotify_rm_watch 286-
94# define __NR_inotify_init1 324-
95#elif defined (__alpha__)-
96# define __NR_inotify_init 444-
97# define __NR_inotify_add_watch 445-
98# define __NR_inotify_rm_watch 446-
99// no inotify_init1 for the Alpha-
100#elif defined (__sparc__) || defined (__sparc64__)-
101# define __NR_inotify_init 151-
102# define __NR_inotify_add_watch 152-
103# define __NR_inotify_rm_watch 156-
104# define __NR_inotify_init1 322-
105#elif defined (__arm__)-
106# define __NR_inotify_init 316-
107# define __NR_inotify_add_watch 317-
108# define __NR_inotify_rm_watch 318-
109# define __NR_inotify_init1 360-
110#elif defined (__sh__)-
111# define __NR_inotify_init 290-
112# define __NR_inotify_add_watch 291-
113# define __NR_inotify_rm_watch 292-
114# define __NR_inotify_init1 332-
115#elif defined (__sh64__)-
116# define __NR_inotify_init 318-
117# define __NR_inotify_add_watch 319-
118# define __NR_inotify_rm_watch 320-
119# define __NR_inotify_init1 360-
120#elif defined (__mips__)-
121# define __NR_inotify_init 284-
122# define __NR_inotify_add_watch 285-
123# define __NR_inotify_rm_watch 286-
124# define __NR_inotify_init1 329-
125#elif defined (__hppa__)-
126# define __NR_inotify_init 269-
127# define __NR_inotify_add_watch 270-
128# define __NR_inotify_rm_watch 271-
129# define __NR_inotify_init1 314-
130#elif defined (__avr32__)-
131# define __NR_inotify_init 240-
132# define __NR_inotify_add_watch 241-
133# define __NR_inotify_rm_watch 242-
134// no inotify_init1 for AVR32-
135#elif defined (__mc68000__)-
136# define __NR_inotify_init 284-
137# define __NR_inotify_add_watch 285-
138# define __NR_inotify_rm_watch 286-
139# define __NR_inotify_init1 328-
140#elif defined (__aarch64__)-
141# define __NR_inotify_init1 26-
142# define __NR_inotify_add_watch 27-
143# define __NR_inotify_rm_watch 28-
144// no inotify_init for aarch64-
145#else-
146# error "This architecture is not supported. Please see http://www.qt-project.org/"-
147#endif-
148-
149#if !defined(IN_CLOEXEC) && defined(O_CLOEXEC) && defined(__NR_inotify_init1)-
150# define IN_CLOEXEC O_CLOEXEC-
151#endif-
152-
153QT_BEGIN_NAMESPACE-
154-
155#ifdef QT_LINUXBASE-
156// ### the LSB doesn't standardize syscall, need to wait until glib2.4 is standardized-
157static inline int syscall(...) { return -1; }-
158#endif-
159-
160static inline int inotify_init()-
161{-
162#ifdef __NR_inotify_init-
163 return syscall(__NR_inotify_init);-
164#else-
165 return syscall(__NR_inotify_init1, 0);-
166#endif-
167}-
168-
169static inline int inotify_add_watch(int fd, const char *name, __u32 mask)-
170{-
171 return syscall(__NR_inotify_add_watch, fd, name, mask);-
172}-
173-
174static inline int inotify_rm_watch(int fd, __u32 wd)-
175{-
176 return syscall(__NR_inotify_rm_watch, fd, wd);-
177}-
178-
179#ifdef IN_CLOEXEC-
180static inline int inotify_init1(int flags)-
181{-
182 return syscall(__NR_inotify_init1, flags);-
183}-
184#endif-
185-
186// the following struct and values are documented in linux/inotify.h-
187extern "C" {-
188-
189struct inotify_event {-
190 __s32 wd;-
191 __u32 mask;-
192 __u32 cookie;-
193 __u32 len;-
194 char name[0];-
195};-
196-
197#define IN_ACCESS 0x00000001-
198#define IN_MODIFY 0x00000002-
199#define IN_ATTRIB 0x00000004-
200#define IN_CLOSE_WRITE 0x00000008-
201#define IN_CLOSE_NOWRITE 0x00000010-
202#define IN_OPEN 0x00000020-
203#define IN_MOVED_FROM 0x00000040-
204#define IN_MOVED_TO 0x00000080-
205#define IN_CREATE 0x00000100-
206#define IN_DELETE 0x00000200-
207#define IN_DELETE_SELF 0x00000400-
208#define IN_MOVE_SELF 0x00000800-
209#define IN_UNMOUNT 0x00002000-
210#define IN_Q_OVERFLOW 0x00004000-
211#define IN_IGNORED 0x00008000-
212-
213#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)-
214#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)-
215}-
216-
217QT_END_NAMESPACE-
218-
219// --------- inotify.h end -----------
220-
221#else /* QT_NO_INOTIFY */-
222-
223#include <sys/inotify.h>-
224-
225#endif-
226-
227QT_BEGIN_NAMESPACE-
228-
229QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create(QObject *parent)-
230{-
231 int fd = -1;-
232#ifdef IN_CLOEXEC-
233 fd = inotify_init1(IN_CLOEXEC);-
234#endif-
235 if (fd == -1) {
fd == -1Description
TRUEnever evaluated
FALSEevaluated 355 times by 10 tests
Evaluated by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
0-355
236 fd = inotify_init();-
237 if (fd == -1)
fd == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
238 return 0;
never executed: return 0;
0
239 }
never executed: end of block
0
240 return new QInotifyFileSystemWatcherEngine(fd, parent);
executed 355 times by 10 tests: return new QInotifyFileSystemWatcherEngine(fd, parent);
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
355
241}-
242-
243QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd, QObject *parent)-
244 : QFileSystemWatcherEngine(parent),-
245 inotifyFd(fd),-
246 notifier(fd, QSocketNotifier::Read, this)-
247{-
248 fcntl(inotifyFd, F_SETFD, FD_CLOEXEC);-
249 connect(&notifier, SIGNAL(activated(int)), SLOT(readFromInotify()));-
250}
executed 355 times by 10 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
355
251-
252QInotifyFileSystemWatcherEngine::~QInotifyFileSystemWatcherEngine()-
253{-
254 notifier.setEnabled(false);-
255 for (int id : qAsConst(pathToID))-
256 inotify_rm_watch(inotifyFd, id < 0 ? -id : id);
executed 361 times by 9 tests: inotify_rm_watch(inotifyFd, id < 0 ? -id : id);
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
  • tst_qfilesystemwatcher - unknown status
361
257-
258 ::close(inotifyFd);-
259}
executed 354 times by 11 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
  • tst_qapplication - unknown status
  • tst_qfilesystemwatcher - unknown status
354
260-
261QStringList QInotifyFileSystemWatcherEngine::addPaths(const QStringList &paths,-
262 QStringList *files,-
263 QStringList *directories)-
264{-
265 QStringList p = paths;-
266 QMutableListIterator<QString> it(p);-
267 while (it.hasNext()) {
it.hasNext()Description
TRUEevaluated 478 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 476 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
476-478
268 QString path = it.next();-
269 QFileInfo fi(path);-
270 bool isDir = fi.isDir();-
271 if (isDir) {
isDirDescription
TRUEevaluated 442 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
36-442
272 if (directories->contains(path))
directories->contains(path)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 441 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
1-441
273 continue;
executed 1 time by 1 test: continue;
Executed by:
  • tst_QFileSystemWatcher
1
274 } else {
executed 441 times by 8 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
441
275 if (files->contains(path))
files->contains(path)Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
0-36
276 continue;
never executed: continue;
0
277 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
36
278-
279 int wd = inotify_add_watch(inotifyFd,-
280 QFile::encodeName(path),-
281 (isDir-
282 ? (0-
283 | IN_ATTRIB-
284 | IN_MOVE-
285 | IN_CREATE-
286 | IN_DELETE-
287 | IN_DELETE_SELF-
288 )-
289 : (0-
290 | IN_ATTRIB-
291 | IN_MODIFY-
292 | IN_MOVE-
293 | IN_MOVE_SELF-
294 | IN_DELETE_SELF-
295 )));-
296 if (wd < 0) {
wd < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 475 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
2-475
297 qWarning().nospace() << "inotify_add_watch(" << path << ") failed: " << QSystemError(errno, QSystemError::NativeError).toString();-
298 continue;
executed 2 times by 1 test: continue;
Executed by:
  • tst_QFileSystemWatcher
2
299 }-
300-
301 it.remove();-
302-
303 int id = isDir ? -wd : wd;
isDirDescription
TRUEevaluated 441 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
34-441
304 if (id < 0) {
id < 0Description
TRUEevaluated 441 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
34-441
305 directories->append(path);-
306 } else {
executed 441 times by 8 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
441
307 files->append(path);-
308 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
34
309-
310 pathToID.insert(path, id);-
311 idToPath.insert(id, path);-
312 }
executed 475 times by 8 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
475
313-
314 return p;
executed 476 times by 8 tests: return p;
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
476
315}-
316-
317QStringList QInotifyFileSystemWatcherEngine::removePaths(const QStringList &paths,-
318 QStringList *files,-
319 QStringList *directories)-
320{-
321 QStringList p = paths;-
322 QMutableListIterator<QString> it(p);-
323 while (it.hasNext()) {
it.hasNext()Description
TRUEevaluated 107 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 106 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
106-107
324 QString path = it.next();-
325 int id = pathToID.take(path);-
326 QString x = idToPath.take(id);-
327 if (x.isEmpty() || x != path)
x.isEmpty()Description
TRUEevaluated 12 times by 3 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
FALSEevaluated 95 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
x != pathDescription
TRUEnever evaluated
FALSEevaluated 95 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
0-95
328 continue;
executed 12 times by 3 tests: continue;
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
12
329-
330 int wd = id < 0 ? -id : id;
id < 0Description
TRUEevaluated 86 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
9-86
331 // qDebug() << "removing watch for path" << path << "wd" << wd;-
332 inotify_rm_watch(inotifyFd, wd);-
333-
334 it.remove();-
335 if (id < 0) {
id < 0Description
TRUEevaluated 86 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
9-86
336 directories->removeAll(path);-
337 } else {
executed 86 times by 5 tests: end of block
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
86
338 files->removeAll(path);-
339 }
executed 9 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
9
340 }-
341-
342 return p;
executed 106 times by 5 tests: return p;
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
106
343}-
344-
345void QInotifyFileSystemWatcherEngine::readFromInotify()-
346{-
347 // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");-
348-
349 int buffSize = 0;-
350 ioctl(inotifyFd, FIONREAD, (char *) &buffSize);-
351 QVarLengthArray<char, 4096> buffer(buffSize);-
352 buffSize = read(inotifyFd, buffer.data(), buffSize);-
353 char *at = buffer.data();-
354 char * const end = at + buffSize;-
355-
356 QHash<int, inotify_event *> eventForId;-
357 while (at < end) {
at < endDescription
TRUEevaluated 222 times by 6 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 106 times by 6 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
106-222
358 inotify_event *event = reinterpret_cast<inotify_event *>(at);-
359-
360 if (eventForId.contains(event->wd))
eventForId.contains(event->wd)Description
TRUEevaluated 98 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_languageChange
FALSEevaluated 124 times by 6 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
98-124
361 eventForId[event->wd]->mask |= event->mask;
executed 98 times by 4 tests: eventForId[event->wd]->mask |= event->mask;
Executed by:
  • tst_QCompleter
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_languageChange
98
362 else-
363 eventForId.insert(event->wd, event);
executed 124 times by 6 tests: eventForId.insert(event->wd, event);
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
124
364-
365 at += sizeof(inotify_event) + event->len;-
366 }
executed 222 times by 6 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
222
367-
368 QHash<int, inotify_event *>::const_iterator it = eventForId.constBegin();-
369 while (it != eventForId.constEnd()) {
it != eventForId.constEnd()Description
TRUEevaluated 124 times by 6 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 106 times by 6 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
106-124
370 const inotify_event &event = **it;-
371 ++it;-
372-
373 // qDebug() << "inotify event, wd" << event.wd << "mask" << hex << event.mask;-
374-
375 int id = event.wd;-
376 QString path = getPathFromID(id);-
377 if (path.isEmpty()) {
path.isEmpty()Description
TRUEevaluated 102 times by 6 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
22-102
378 // perhaps a directory?-
379 id = -id;-
380 path = getPathFromID(id);-
381 if (path.isEmpty())
path.isEmpty()Description
TRUEevaluated 44 times by 4 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 58 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
44-58
382 continue;
executed 44 times by 4 tests: continue;
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
44
383 }
executed 58 times by 4 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
58
384-
385 // qDebug() << "event for path" << path;-
386-
387 if ((event.mask & (IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT)) != 0) {
(event.mask & ...0002000)) != 0Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 62 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
18-62
388 pathToID.remove(path);-
389 idToPath.remove(id, getPathFromID(id));-
390 if (!idToPath.contains(id))
!idToPath.contains(id)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
9
391 inotify_rm_watch(inotifyFd, event.wd);
executed 9 times by 1 test: inotify_rm_watch(inotifyFd, event.wd);
Executed by:
  • tst_QFileSystemWatcher
9
392-
393 if (id < 0)
id < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
4-14
394 emit directoryChanged(path, true);
executed 4 times by 1 test: directoryChanged(path, true);
Executed by:
  • tst_QFileSystemWatcher
4
395 else-
396 emit fileChanged(path, true);
executed 14 times by 1 test: fileChanged(path, true);
Executed by:
  • tst_QFileSystemWatcher
14
397 } else {-
398 if (id < 0)
id < 0Description
TRUEevaluated 54 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
8-54
399 emit directoryChanged(path, false);
executed 54 times by 4 tests: directoryChanged(path, false);
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
54
400 else-
401 emit fileChanged(path, false);
executed 8 times by 1 test: fileChanged(path, false);
Executed by:
  • tst_QFileSystemWatcher
8
402 }-
403 }-
404}
executed 106 times by 6 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
106
405-
406QString QInotifyFileSystemWatcherEngine::getPathFromID(int id) const-
407{-
408 QHash<int, QString>::const_iterator i = idToPath.find(id);-
409 while (i != idToPath.constEnd() && i.key() == id) {
i != idToPath.constEnd()Description
TRUEevaluated 116 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
FALSEevaluated 146 times by 6 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
i.key() == idDescription
TRUEevaluated 116 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
FALSEnever evaluated
0-146
410 if ((i + 1) == idToPath.constEnd() || (i + 1).key() != id) {
(i + 1) == idToPath.constEnd()Description
TRUEevaluated 76 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
(i + 1).key() != idDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
18-76
411 return i.value();
executed 98 times by 4 tests: return i.value();
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
98
412 }-
413 ++i;-
414 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
18
415 return QString();
executed 146 times by 6 tests: return QString();
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
146
416}-
417-
418QT_END_NAMESPACE-
419-
420#endif // QT_NO_FILESYSTEMWATCHER-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9