From 78437ef0d2d662663bbc827befc849cad5886b63 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 11 Sep 2019 09:29:40 +0200 Subject: Add qt.core.filesystemwatcher logging category QFileSystemWatcher has open bugs, so users should be able to help troubleshoot. Change-Id: I6b703e25f294944469d20fd36012b6a55133732a Reviewed-by: Friedemann Kleint --- src/corelib/io/qfilesystemwatcher.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 64c422c55a..a4705136a2 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -41,9 +41,9 @@ #include "qfilesystemwatcher_p.h" #include -#include #include #include +#include #include #include @@ -67,6 +67,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcWatcher, "qt.core.filesystemwatcher") + QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent) { #if defined(Q_OS_WIN) @@ -137,6 +139,7 @@ void QFileSystemWatcherPrivate::initPollerEngine() void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed) { Q_Q(QFileSystemWatcher); + qCDebug(lcWatcher) << "file changed" << path << "removed?" << removed << "watching?" << files.contains(path); if (!files.contains(path)) { // the path was removed after a change was detected, but before we delivered the signal return; @@ -149,6 +152,7 @@ void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed) { Q_Q(QFileSystemWatcher); + qCDebug(lcWatcher) << "directory changed" << path << "removed?" << removed << "watching?" << directories.contains(path); if (!directories.contains(path)) { // perhaps the path was removed after a change was detected, but before we delivered the signal return; @@ -355,7 +359,7 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths) qWarning("QFileSystemWatcher::addPaths: list is empty"); return p; } - + qCDebug(lcWatcher) << "adding" << paths; const auto selectEngine = [this, d]() -> QFileSystemWatcherEngine* { #ifdef QT_BUILD_INTERNAL const QString on = objectName(); @@ -364,11 +368,11 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths) // Autotest override case - use the explicitly selected engine only const QStringRef forceName = on.midRef(26); if (forceName == QLatin1String("poller")) { - qDebug("QFileSystemWatcher: skipping native engine, using only polling engine"); + qCDebug(lcWatcher, "QFileSystemWatcher: skipping native engine, using only polling engine"); d_func()->initPollerEngine(); return d->poller; } else if (forceName == QLatin1String("native")) { - qDebug("QFileSystemWatcher: skipping polling engine, using only native engine"); + qCDebug(lcWatcher, "QFileSystemWatcher: skipping polling engine, using only native engine"); return d->native; } return nullptr; @@ -431,6 +435,7 @@ QStringList QFileSystemWatcher::removePaths(const QStringList &paths) qWarning("QFileSystemWatcher::removePaths: list is empty"); return p; } + qCDebug(lcWatcher) << "removing" << paths; if (d->native) p = d->native->removePaths(p, &d->files, &d->directories); -- cgit v1.2.3