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