diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2012-01-12 11:40:51 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-12 14:38:18 +0100 |
commit | 9834b3681fb02ef5eaab19d678b674365a4381e4 (patch) | |
tree | 70b2d8beea25698909a146b2dec5b6e23e74a2fa /src/corelib/io/qfilesystemwatcher.cpp | |
parent | 716905cd5675497f0c99e9468bc52ed6e6e25005 (diff) |
Make QFileSystemWatcherEngines children of QFileSystemWatcher
To support moving QFileSystemWatcher to another thread, the engines need
to follow when the watcher is moved. The easiest way to do this is by
parenting the engines to the watcher.
Change-Id: Ie2bb701c0c148da9cc2302d4de23286b8ef42c4d
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qfilesystemwatcher.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemwatcher.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index b6eb5eda5a..4abb4f3cc1 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -63,16 +63,16 @@ QT_BEGIN_NAMESPACE -QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine() +QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent) { #if defined(Q_OS_WIN) - return new QWindowsFileSystemWatcherEngine; + return new QWindowsFileSystemWatcherEngine(parent); #elif defined(Q_OS_LINUX) // there is a chance that inotify may fail on Linux pre-2.6.13 (August // 2005), so we can't just new inotify directly. - return QInotifyFileSystemWatcherEngine::create(); + return QInotifyFileSystemWatcherEngine::create(parent); #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) - return QKqueueFileSystemWatcherEngine::create(); + return QKqueueFileSystemWatcherEngine::create(parent); #else return 0; #endif @@ -86,7 +86,7 @@ QFileSystemWatcherPrivate::QFileSystemWatcherPrivate() void QFileSystemWatcherPrivate::init() { Q_Q(QFileSystemWatcher); - native = createNativeEngine(); + native = createNativeEngine(q); if (native) { QObject::connect(native, SIGNAL(fileChanged(QString,bool)), @@ -105,7 +105,7 @@ void QFileSystemWatcherPrivate::initPollerEngine() return; Q_Q(QFileSystemWatcher); - poller = new QPollingFileSystemWatcherEngine; // that was a mouthful + poller = new QPollingFileSystemWatcherEngine(q); // that was a mouthful QObject::connect(poller, SIGNAL(fileChanged(QString,bool)), q, @@ -216,17 +216,7 @@ QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent Destroys the file system watcher. */ QFileSystemWatcher::~QFileSystemWatcher() -{ - Q_D(QFileSystemWatcher); - if (d->native) { - delete d->native; - d->native = 0; - } - if (d->poller) { - delete d->poller; - d->poller = 0; - } -} +{ } /*! Adds \a path to the file system watcher if \a path exists. The |