Details
-
Suggestion
-
Resolution: Out of scope
-
P2: Important
-
4.4.0
-
None
-
-
317278
Description
Using one instance of QFileSystemWatcher and watching 255 files issues a warning:
QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: files/file241.txt
If it cannot be fixed, should be documented.
Example which reproduces that:
#include <QApplication> #include <QPlainTextEdit> #include <QFileSystemWatcher> #include <QVBoxLayout> #include <QFile> #include <QDir> #include <QTextStream> class MyWidget : public QWidget { Q_OBJECT public: MyWidget(QWidget *parent = 0) : QWidget(parent) { int N = 300; QDir d("."); d.mkdir("files"); for (int i = 0; i < N; i++) { QFile file(QString("files/file%1.txt").arg(i)); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out << "File contents " << i; } QLayout *l = new QVBoxLayout(this); pte = new QPlainTextEdit(this); l->addWidget(pte); QFileSystemWatcher *fsw = new QFileSystemWatcher(this); connect(fsw, SIGNAL(fileChanged(const QString &)), this, SLOT(fileChanged(const QString &))); for (int i = 0; i < N; i++) { fsw->addPath(QString("files/file%1.txt").arg(i)); } } public slots: void fileChanged(const QString &path) { pte->appendPlainText(path); } private: QPlainTextEdit *pte; }; int main(int argc, char **argv) { QApplication app(argc, argv); MyWidget w; w.show(); return app.exec(); } #include "main.moc"