FileSystemWatcher Classclass Utils::FileSystemWatcher
The FileSystemWatcher class is a file watcher that internally uses a centralized QFileSystemWatcher and enforces limits on Mac OS. More...
|FileSystemWatcher(int id, QObject *parent = nullptr)|
|FileSystemWatcher(QObject *parent = nullptr)|
Constructing/Destructing a QFileSystemWatcher is expensive. This can be worked around by using a centralized watcher.
Note: It is (still) possible to create several instances of a QFileSystemWatcher by passing an (arbitrary) integer id != 0 to the constructor. This allows separating watchers that easily exceed operating system limits from others (see below).
Mac OS Specifics
There is a hard limit on the number of file handles that can be open at one point per process on Mac OS X (e.g. it is 2560 on Mac OS X Snow Leopard Server, as shown by
ulimit -a). Opening one or several
.qmlproject's with a large number of directories to watch easily exceeds this. The results are crashes later on, e.g. when threads cannot be created any more.
This class implements a heuristic that the file system watcher used for
.qmlproject files never uses more than half the number of available file handles. It also increases the number from
rlim_max - the old code in main.cpp failed, see last section in
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.