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
void QFileSystemWatcherPrivate::init()
{
Q_Q(QFileSystemWatcher);
- native = createNativeEngine();
+ native = createNativeEngine(q);
if (native) {
QObject::connect(native,
SIGNAL(fileChanged(QString,bool)),
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,
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
QT_BEGIN_NAMESPACE
-QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create()
+QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create(QObject *parent)
{
register int fd = -1;
#ifdef IN_CLOEXEC
if (fd == -1)
return 0;
}
- return new QInotifyFileSystemWatcherEngine(fd);
+ return new QInotifyFileSystemWatcherEngine(fd, parent);
}
-QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd)
- : inotifyFd(fd)
- , notifier(fd, QSocketNotifier::Read, this)
+QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd, QObject *parent)
+ : QFileSystemWatcherEngine(parent),
+ inotifyFd(fd),
+ notifier(fd, QSocketNotifier::Read, this)
{
fcntl(inotifyFd, F_SETFD, FD_CLOEXEC);
connect(¬ifier, SIGNAL(activated(int)), SLOT(readFromInotify()));
public:
~QInotifyFileSystemWatcherEngine();
- static QInotifyFileSystemWatcherEngine *create();
+ static QInotifyFileSystemWatcherEngine *create(QObject *parent);
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
void readFromInotify();
private:
- QInotifyFileSystemWatcherEngine(int fd);
+ QInotifyFileSystemWatcherEngine(int fd, QObject *parent);
int inotifyFd;
QHash<QString, int> pathToID;
QHash<int, QString> idToPath;
# define DEBUG if(false)qDebug
#endif
-QKqueueFileSystemWatcherEngine *QKqueueFileSystemWatcherEngine::create()
+QKqueueFileSystemWatcherEngine *QKqueueFileSystemWatcherEngine::create(QObject *parent)
{
int kqfd = kqueue();
if (kqfd == -1)
return 0;
- return new QKqueueFileSystemWatcherEngine(kqfd);
+ return new QKqueueFileSystemWatcherEngine(kqfd, parent);
}
-QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd)
- : kqfd(kqfd)
- , notifier(kqfd, QSocketNotifier::Read, this)
+QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd, QObject *parent)
+ : QFileSystemWatcherEngine(parent),
+ kqfd(kqfd),
+ notifier(kqfd, QSocketNotifier::Read, this)
{
connect(¬ifier, SIGNAL(activated(int)), SLOT(readFromKqueue()));
public:
~QKqueueFileSystemWatcherEngine();
- static QKqueueFileSystemWatcherEngine *create();
+ static QKqueueFileSystemWatcherEngine *create(QObject *parent);
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
void readFromKqueue();
private:
- QKqueueFileSystemWatcherEngine(int kqfd);
+ QKqueueFileSystemWatcherEngine(int kqfd, QObject *parent);
int kqfd;
Q_OBJECT
protected:
- inline QFileSystemWatcherEngine()
+ inline QFileSystemWatcherEngine(QObject *parent)
+ : QObject(parent)
{
}
{
Q_DECLARE_PUBLIC(QFileSystemWatcher)
- static QFileSystemWatcherEngine *createNativeEngine();
+ static QFileSystemWatcherEngine *createNativeEngine(QObject *parent);
public:
QFileSystemWatcherPrivate();
QT_BEGIN_NAMESPACE
-QPollingFileSystemWatcherEngine::QPollingFileSystemWatcherEngine()
- : timer(this)
+QPollingFileSystemWatcherEngine::QPollingFileSystemWatcherEngine(QObject *parent)
+ : QFileSystemWatcherEngine(parent),
+ timer(this)
{
connect(&timer, SIGNAL(timeout()), SLOT(timeout()));
}
QHash<QString, FileInfo> files, directories;
public:
- QPollingFileSystemWatcherEngine();
+ QPollingFileSystemWatcherEngine(QObject *parent);
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
{
Q_OBJECT
public:
+ inline QWindowsFileSystemWatcherEngine(QObject *parent)
+ : QFileSystemWatcherEngine(parent)
+ { }
~QWindowsFileSystemWatcherEngine();
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);