Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2478

Document limitation of FileSystemWatcher on Mac OS X

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • P2: Important
    • Some future release
    • 4.4.0
    • Documentation
    • None
    • macOS
    • 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"
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            jkobus Jarek Kobus
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes