diff options
Diffstat (limited to 'src/corelib/io/qfilesystemwatcher.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemwatcher.cpp | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 9ffbe31d3d..064be4c211 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -9,7 +9,6 @@ #include <qfileinfo.h> #include <qloggingcategory.h> #include <qset.h> -#include <qtimer.h> #if (defined(Q_OS_LINUX) || defined(Q_OS_QNX)) && QT_CONFIG(inotify) #define USE_INOTIFY @@ -33,7 +32,7 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; -Q_LOGGING_CATEGORY(lcWatcher, "qt.core.filesystemwatcher") +Q_STATIC_LOGGING_CATEGORY(lcWatcher, "qt.core.filesystemwatcher") QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent) { @@ -58,29 +57,29 @@ QFileSystemWatcherPrivate::QFileSystemWatcherPrivate() { } +void QFileSystemWatcherPrivate::connectEngine(QFileSystemWatcherEngine *engine) +{ + QObjectPrivate::connect(engine, &QFileSystemWatcherEngine::fileChanged, + this, &QFileSystemWatcherPrivate::fileChanged); + QObjectPrivate::connect(engine, &QFileSystemWatcherEngine::directoryChanged, + this, &QFileSystemWatcherPrivate::directoryChanged); +} + void QFileSystemWatcherPrivate::init() { Q_Q(QFileSystemWatcher); native = createNativeEngine(q); if (native) { - QObject::connect(native, - SIGNAL(fileChanged(QString,bool)), - q, - SLOT(_q_fileChanged(QString,bool))); - QObject::connect(native, - SIGNAL(directoryChanged(QString,bool)), - q, - SLOT(_q_directoryChanged(QString,bool))); + connectEngine(native); #if defined(Q_OS_WIN) - QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native), - &QWindowsFileSystemWatcherEngine::driveLockForRemoval, - q, [this] (const QString &p) { _q_winDriveLockForRemoval(p); }); - QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native), - &QWindowsFileSystemWatcherEngine::driveLockForRemovalFailed, - q, [this] (const QString &p) { _q_winDriveLockForRemovalFailed(p); }); - QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native), - &QWindowsFileSystemWatcherEngine::driveRemoved, - q, [this] (const QString &p) { _q_winDriveRemoved(p); }); + auto *windowsWatcher = static_cast<QWindowsFileSystemWatcherEngine *>(native); + using WinE = QWindowsFileSystemWatcherEngine; + QObjectPrivate::connect(windowsWatcher, &WinE::driveLockForRemoval, + this, &QFileSystemWatcherPrivate::winDriveLockForRemoval); + QObjectPrivate::connect(windowsWatcher, &WinE::driveLockForRemovalFailed, + this, &QFileSystemWatcherPrivate::winDriveLockForRemovalFailed); + QObjectPrivate::connect(windowsWatcher, &WinE::driveRemoved, + this, &QFileSystemWatcherPrivate::winDriveRemoved); #endif // Q_OS_WIN } } @@ -92,17 +91,10 @@ void QFileSystemWatcherPrivate::initPollerEngine() Q_Q(QFileSystemWatcher); poller = new QPollingFileSystemWatcherEngine(q); // that was a mouthful - QObject::connect(poller, - SIGNAL(fileChanged(QString,bool)), - q, - SLOT(_q_fileChanged(QString,bool))); - QObject::connect(poller, - SIGNAL(directoryChanged(QString,bool)), - q, - SLOT(_q_directoryChanged(QString,bool))); + connectEngine(poller); } -void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed) +void QFileSystemWatcherPrivate::fileChanged(const QString &path, bool removed) { Q_Q(QFileSystemWatcher); qCDebug(lcWatcher) << "file changed" << path << "removed?" << removed << "watching?" << files.contains(path); @@ -115,7 +107,7 @@ void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed emit q->fileChanged(path, QFileSystemWatcher::QPrivateSignal()); } -void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed) +void QFileSystemWatcherPrivate::directoryChanged(const QString &path, bool removed) { Q_Q(QFileSystemWatcher); qCDebug(lcWatcher) << "directory changed" << path << "removed?" << removed << "watching?" << directories.contains(path); @@ -130,7 +122,7 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re #if defined(Q_OS_WIN) -void QFileSystemWatcherPrivate::_q_winDriveLockForRemoval(const QString &path) +void QFileSystemWatcherPrivate::winDriveLockForRemoval(const QString &path) { // Windows: Request to lock a (removable/USB) drive for removal, release // its paths under watch, temporarily storing them should the lock fail. @@ -147,7 +139,7 @@ void QFileSystemWatcherPrivate::_q_winDriveLockForRemoval(const QString &path) } } -void QFileSystemWatcherPrivate::_q_winDriveLockForRemovalFailed(const QString &path) +void QFileSystemWatcherPrivate::winDriveLockForRemovalFailed(const QString &path) { // Windows: Request to lock a (removable/USB) drive failed (blocked by other // application), restore the watched paths. @@ -161,7 +153,7 @@ void QFileSystemWatcherPrivate::_q_winDriveLockForRemovalFailed(const QString &p } } -void QFileSystemWatcherPrivate::_q_winDriveRemoved(const QString &path) +void QFileSystemWatcherPrivate::winDriveRemoved(const QString &path) { // Windows: Drive finally removed, clear out paths stored in lock request. if (!path.isEmpty()) |