Qt 4.8
Public Functions | Static Public Functions | Private Functions | Static Private Functions | Properties | List of all members
QFSEventsFileSystemWatcherEngine Class Reference

#include <qfilesystemwatcher_fsevents_p.h>

Inheritance diagram for QFSEventsFileSystemWatcherEngine:
QFileSystemWatcherEngine QThread QObject

Public Functions

QStringList addPaths (const QStringList &paths, QStringList *files, QStringList *directories)
 
QStringList removePaths (const QStringList &paths, QStringList *files, QStringList *directories)
 
void stop ()
 
 ~QFSEventsFileSystemWatcherEngine ()
 
- Public Functions inherited from QThread
void exit (int retcode=0)
 Tells the thread's event loop to exit with a return code. More...
 
bool isFinished () const
 Returns true if the thread is finished; otherwise returns false. More...
 
bool isRunning () const
 Returns true if the thread is running; otherwise returns false. More...
 
Priority priority () const
 Returns the priority for a running thread. More...
 
 QThread (QObject *parent=0)
 Constructs a new QThread to manage a new thread. More...
 
void setPriority (Priority priority)
 This function sets the priority for a running thread. More...
 
void setStackSize (uint stackSize)
 Sets the maximum stack size for the thread to stackSize. More...
 
uint stackSize () const
 Returns the maximum stack size for the thread (if set with setStackSize()); otherwise returns zero. More...
 
bool wait (unsigned long time=ULONG_MAX)
 Blocks the thread until either of these conditions is met: More...
 
 ~QThread ()
 Destroys the QThread. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static QFSEventsFileSystemWatcherEnginecreate ()
 
- Static Public Functions inherited from QThread
static QThreadcurrentThread ()
 Returns a pointer to a QThread which manages the currently executing thread. More...
 
static Qt::HANDLE currentThreadId ()
 Returns the thread handle of the currently executing thread. More...
 
static int idealThreadCount ()
 Returns the ideal number of threads that can be run on the system. More...
 
static void yieldCurrentThread ()
 Yields execution of the current thread to another runnable thread, if any. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Private Functions

 QFSEventsFileSystemWatcherEngine ()
 
void run ()
 The starting point for the thread. More...
 
void updateFiles ()
 
void warmUpFSEvents ()
 

Static Private Functions

static void fseventsCallback (ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[])
 

Properties

FSEventStreamRef fsStream
 
QMutex mutex
 
CFArrayRef pathsToWatch
 
CFRunLoopRef threadsRunLoop
 
QWaitCondition waitCondition
 
QWaitCondition waitForStop
 

Additional Inherited Members

- Public Types inherited from QThread
enum  Priority {
  IdlePriority, LowestPriority, LowPriority, NormalPriority,
  HighPriority, HighestPriority, TimeCriticalPriority, InheritPriority
}
 This enum type indicates how the operating system should schedule newly created threads. More...
 
- Public Slots inherited from QThread
void quit ()
 Tells the thread's event loop to exit with return code 0 (success). More...
 
void start (Priority=InheritPriority)
 Begins execution of the thread by calling run(). More...
 
void terminate ()
 Terminates the execution of the thread. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QFileSystemWatcherEngine
void directoryChanged (const QString &path, bool removed)
 
void fileChanged (const QString &path, bool removed)
 
- Signals inherited from QThread
void finished ()
 This signal is emitted when the thread has finished executing. More...
 
void started ()
 This signal is emitted when the thread starts executing. More...
 
void terminated ()
 This signal is emitted when the thread is terminated. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QFileSystemWatcherEngine
 QFileSystemWatcherEngine (bool move=true)
 
- Protected Functions inherited from QThread
int exec ()
 Enters the event loop and waits until exit() is called, returning the value that was passed to exit(). More...
 
 QThread (QThreadPrivate &dd, QObject *parent=0)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Static Protected Functions inherited from QThread
static void msleep (unsigned long)
 Forces the current thread to sleep for msecs milliseconds. More...
 
static void setTerminationEnabled (bool enabled=true)
 Enables or disables termination of the current thread based on the enabled parameter. More...
 
static void sleep (unsigned long)
 Forces the current thread to sleep for secs seconds. More...
 
static void usleep (unsigned long)
 Forces the current thread to sleep for usecs microseconds. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 92 of file qfilesystemwatcher_fsevents_p.h.

Constructors and Destructors

◆ ~QFSEventsFileSystemWatcherEngine()

QFSEventsFileSystemWatcherEngine::~QFSEventsFileSystemWatcherEngine ( )

Definition at line 155 of file qfilesystemwatcher_fsevents.cpp.

156 {
157 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
158  // I assume that at this point, QFileSystemWatcher has already called stop
159  // on me, so I don't need to invalidate or stop my stream, simply
160  // release it.
161  cleanupFSStream(fsStream);
162  if (pathsToWatch)
163  CFRelease(pathsToWatch);
164 #endif
165 }

◆ QFSEventsFileSystemWatcherEngine()

QFSEventsFileSystemWatcherEngine::QFSEventsFileSystemWatcherEngine ( )
private

Functions

◆ addPaths()

QStringList QFSEventsFileSystemWatcherEngine::addPaths ( const QStringList paths,
QStringList files,
QStringList directories 
)
virtual

Implements QFileSystemWatcherEngine.

Definition at line 172 of file qfilesystemwatcher_fsevents.cpp.

175 {
176 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
177  stop();
178  wait();
179  QMutexLocker locker(&mutex);
180  QStringList failedToAdd;
181  // if we have a running FSStreamEvent, we have to kill it, we'll re-add the stream soon.
182  FSEventStreamEventId idToCheck;
183  if (fsStream) {
184  idToCheck = FSEventStreamGetLatestEventId(fsStream);
185  cleanupFSStream(fsStream);
186  } else {
187  idToCheck = kFSEventStreamEventIdSinceNow;
188  }
189 
190  // Brain-dead approach, but works. FSEvents actually can already read sub-trees, but since it's
191  // work to figure out if we are doing a double register, we just register it twice as FSEvents
192  // seems smart enough to only deliver one event. We also duplicate directory entries in here
193  // (e.g., if you watch five files in the same directory, you get that directory included in the
194  // array 5 times). This stupidity also makes remove work correctly though. I'll freely admit
195  // that we could make this a bit smarter. If you do, check the auto-tests, they should catch at
196  // least a couple of the issues.
197  QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
198  for (int i = 0; i < paths.size(); ++i) {
199  const QString &path = paths.at(i);
200 
201  QFileInfo fileInfo(path);
202  if (!fileInfo.exists()) {
203  failedToAdd.append(path);
204  continue;
205  }
206 
207  if (fileInfo.isDir()) {
208  if (directories->contains(path)) {
209  failedToAdd.append(path);
210  continue;
211  } else {
212  directories->append(path);
213  // Full file path for dirs.
214  QCFString cfpath(createFSStreamPath(fileInfo.canonicalFilePath()));
215  addPathToHash(dirPathInfoHash, cfpath, fileInfo, path);
216  CFArrayAppendValue(tmpArray, cfpath);
217  }
218  } else {
219  if (files->contains(path)) {
220  failedToAdd.append(path);
221  continue;
222  } else {
223  // Just the absolute path (minus it's filename) for files.
224  QCFString cfpath(createFSStreamPath(fileInfo.canonicalPath()));
225  files->append(path);
226  addPathToHash(filePathInfoHash, cfpath, fileInfo, path);
227  CFArrayAppendValue(tmpArray, cfpath);
228  }
229  }
230  }
231 
232  if (!pathsToWatch && failedToAdd.size() == paths.size()) {
233  return failedToAdd;
234  }
235 
236  if (CFArrayGetCount(tmpArray) > 0) {
237  if (pathsToWatch) {
238  CFArrayAppendArray(tmpArray, pathsToWatch, CFRangeMake(0, CFArrayGetCount(pathsToWatch)));
239  CFRelease(pathsToWatch);
240  }
241  pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray);
242  }
243 
244  FSEventStreamContext context = { 0, this, 0, 0, 0 };
245  fsStream = FSEventStreamCreate(kCFAllocatorDefault,
247  &context, pathsToWatch,
248  idToCheck, Latency, QtFSEventFlags);
249  warmUpFSEvents();
250 
251  return failedToAdd;
252 #else
253  Q_UNUSED(paths);
254  Q_UNUSED(files);
255  Q_UNUSED(directories);
256  return QStringList();
257 #endif
258 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
static void fseventsCallback(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[])
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool wait(unsigned long time=ULONG_MAX)
Blocks the thread until either of these conditions is met:
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
uint64_t FSEventStreamEventId
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ create()

QFSEventsFileSystemWatcherEngine * QFSEventsFileSystemWatcherEngine::create ( )
static

Definition at line 167 of file qfilesystemwatcher_fsevents.cpp.

◆ fseventsCallback()

void QFSEventsFileSystemWatcherEngine::fseventsCallback ( ConstFSEventStreamRef  streamRef,
void *  clientCallBackInfo,
size_t  numEvents,
void *  eventPaths,
const FSEventStreamEventFlags  eventFlags[],
const FSEventStreamEventId  eventIds[] 
)
staticprivate

Definition at line 395 of file qfilesystemwatcher_fsevents.cpp.

Referenced by addPaths(), and removePaths().

400 {
401 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
402  QFSEventsFileSystemWatcherEngine *watcher = static_cast<QFSEventsFileSystemWatcherEngine *>(clientCallBackInfo);
403  QMutexLocker locker(&watcher->mutex);
404  CFArrayRef paths = static_cast<CFArrayRef>(eventPaths);
405  for (size_t i = 0; i < numEvents; ++i) {
406  const QString path = QCFString::toQString(
407  static_cast<CFStringRef>(CFArrayGetValueAtIndex(paths, i)));
408  const FSEventStreamEventFlags pathFlags = eventFlags[i];
409  // There are several flags that may be passed, but we really don't care about them ATM.
410  // Here they are and why we don't care.
411  // kFSEventStreamEventFlagHistoryDone--(very unlikely to be gotten, but even then, not much changes).
412  // kFSEventStreamEventFlagMustScanSubDirs--Likely means the data is very much out of date, we
413  // aren't coalescing our directories, so again not so much of an issue
414  // kFSEventStreamEventFlagRootChanged | kFSEventStreamEventFlagMount | kFSEventStreamEventFlagUnmount--
415  // These three flags indicate something has changed, but the stat will likely show this, so
416  // there's not really much to worry about.
417  // (btw, FSEvents is not the correct way of checking for mounts/unmounts,
418  // there are real CarbonCore events for that.)
419  Q_UNUSED(pathFlags);
420  if (watcher->filePathInfoHash.contains(path))
421  watcher->updateList(watcher->filePathInfoHash[path], false, true);
422 
423  if (watcher->dirPathInfoHash.contains(path))
424  watcher->updateList(watcher->dirPathInfoHash[path], true, true);
425  }
426 #else
427  Q_UNUSED(clientCallBackInfo);
428  Q_UNUSED(numEvents);
429  Q_UNUSED(eventPaths);
430  Q_UNUSED(eventFlags);
431 #endif
432 }
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
UInt32 FSEventStreamEventFlags
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
const struct __CFArray * CFArrayRef
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ removePaths()

QStringList QFSEventsFileSystemWatcherEngine::removePaths ( const QStringList paths,
QStringList files,
QStringList directories 
)
virtual

Implements QFileSystemWatcherEngine.

Definition at line 270 of file qfilesystemwatcher_fsevents.cpp.

273 {
274 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
275  stop();
276  wait();
277  QMutexLocker locker(&mutex);
278  // short circuit for smarties that call remove before add and we have nothing.
279  if (pathsToWatch == 0)
280  return paths;
281  QStringList failedToRemove;
282  // if we have a running FSStreamEvent, we have to stop it, we'll re-add the stream soon.
283  FSEventStreamEventId idToCheck;
284  if (fsStream) {
285  idToCheck = FSEventStreamGetLatestEventId(fsStream);
286  cleanupFSStream(fsStream);
287  fsStream = 0;
288  } else {
289  idToCheck = kFSEventStreamEventIdSinceNow;
290  }
291 
292  CFIndex itemCount = CFArrayGetCount(pathsToWatch);
293  QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutableCopy(kCFAllocatorDefault, itemCount,
294  pathsToWatch);
295  CFRelease(pathsToWatch);
296  pathsToWatch = 0;
297  for (int i = 0; i < paths.size(); ++i) {
298  // Get the itemCount at the beginning to avoid any overruns during the iteration.
299  itemCount = CFArrayGetCount(tmpArray);
300  const QString &path = paths.at(i);
301  QFileInfo fi(path);
302  QCFString cfpath(createFSStreamPath(fi.canonicalPath()));
303 
304  CFIndex index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfpath);
305  if (index != -1) {
306  CFArrayRemoveValueAtIndex(tmpArray, index);
307  files->removeAll(path);
308  removePathFromHash(filePathInfoHash, cfpath, path);
309  } else {
310  // Could be a directory we are watching instead.
311  QCFString cfdirpath(createFSStreamPath(fi.canonicalFilePath()));
312  index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfdirpath);
313  if (index != -1) {
314  CFArrayRemoveValueAtIndex(tmpArray, index);
315  directories->removeAll(path);
316  removePathFromHash(dirPathInfoHash, cfpath, path);
317  } else {
318  failedToRemove.append(path);
319  }
320  }
321  }
322  itemCount = CFArrayGetCount(tmpArray);
323  if (itemCount != 0) {
324  pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray);
325 
326  FSEventStreamContext context = { 0, this, 0, 0, 0 };
327  fsStream = FSEventStreamCreate(kCFAllocatorDefault,
329  &context, pathsToWatch, idToCheck, Latency, QtFSEventFlags);
330  warmUpFSEvents();
331  }
332  return failedToRemove;
333 #else
334  Q_UNUSED(paths);
335  Q_UNUSED(files);
336  Q_UNUSED(directories);
337  return QStringList();
338 #endif
339 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static void fseventsCallback(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[])
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool wait(unsigned long time=ULONG_MAX)
Blocks the thread until either of these conditions is met:
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index
uint64_t FSEventStreamEventId
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ run()

void QFSEventsFileSystemWatcherEngine::run ( void  )
privatevirtual

The starting point for the thread.

After calling start(), the newly created thread calls this function. The default implementation simply calls exec().

You can reimplement this function to facilitate advanced thread management. Returning from this method will end the execution of the thread.

See also
start() wait()

Reimplemented from QThread.

Definition at line 470 of file qfilesystemwatcher_fsevents.cpp.

471 {
472 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
473  threadsRunLoop = CFRunLoopGetCurrent();
474  FSEventStreamScheduleWithRunLoop(fsStream, threadsRunLoop, kCFRunLoopDefaultMode);
475  bool startedOK = FSEventStreamStart(fsStream);
476  // It's recommended by Apple that you only update the files after you've started
477  // the stream, because otherwise you might miss an update in between starting it.
478  updateFiles();
479 #ifdef QT_NO_DEBUG
480  Q_UNUSED(startedOK);
481 #else
482  Q_ASSERT(startedOK);
483 #endif
484  // If for some reason we called stop up above (and invalidated our stream), this call will return
485  // immediately.
486  CFRunLoopRun();
487  threadsRunLoop = 0;
488  QMutexLocker locker(&mutex);
490 #endif
491 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ stop()

void QFSEventsFileSystemWatcherEngine::stop ( )
virtual

Implements QFileSystemWatcherEngine.

Definition at line 434 of file qfilesystemwatcher_fsevents.cpp.

Referenced by addPaths(), and removePaths().

435 {
436 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
437  QMutexLocker locker(&mutex);
438  stopFSStream(fsStream);
439  if (threadsRunLoop) {
440  CFRunLoopStop(threadsRunLoop);
442  }
443 #endif
444 }
bool wait(QMutex *mutex, unsigned long time=ULONG_MAX)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ updateFiles()

void QFSEventsFileSystemWatcherEngine::updateFiles ( )
private

Definition at line 446 of file qfilesystemwatcher_fsevents.cpp.

Referenced by run().

447 {
448 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
449  QMutexLocker locker(&mutex);
450  updateHash(filePathInfoHash);
451  updateHash(dirPathInfoHash);
452  if (filePathInfoHash.isEmpty() && dirPathInfoHash.isEmpty()) {
453  // Everything disappeared before we got to start, don't bother.
454 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
455  // Code duplicated from stop(), with the exception that we
456  // don't wait on waitForStop here. Doing this will lead to
457  // a deadlock since this function is called from the worker
458  // thread. (waitForStop.wakeAll() is only called from the
459  // end of run()).
460  stopFSStream(fsStream);
461  if (threadsRunLoop)
462  CFRunLoopStop(threadsRunLoop);
463 #endif
464  cleanupFSStream(fsStream);
465  }
467 #endif
468 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ warmUpFSEvents()

void QFSEventsFileSystemWatcherEngine::warmUpFSEvents ( )
private

Definition at line 260 of file qfilesystemwatcher_fsevents.cpp.

Referenced by addPaths(), and removePaths().

261 {
262 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
263  // This function assumes that the mutex has already been grabbed before calling it.
264  // It exits with the mutex still locked (Q_ASSERT(mutex.isLocked()) ;-).
265  start();
267 #endif
268 }
bool wait(QMutex *mutex, unsigned long time=ULONG_MAX)
void start(Priority=InheritPriority)
Begins execution of the thread by calling run().

Properties

◆ fsStream

FSEventStreamRef QFSEventsFileSystemWatcherEngine::fsStream
private

◆ mutex

QMutex QFSEventsFileSystemWatcherEngine::mutex
private

◆ pathsToWatch

CFArrayRef QFSEventsFileSystemWatcherEngine::pathsToWatch
private

◆ threadsRunLoop

CFRunLoopRef QFSEventsFileSystemWatcherEngine::threadsRunLoop
private

Definition at line 116 of file qfilesystemwatcher_fsevents_p.h.

Referenced by run(), stop(), and updateFiles().

◆ waitCondition

QWaitCondition QFSEventsFileSystemWatcherEngine::waitCondition
private

Definition at line 118 of file qfilesystemwatcher_fsevents_p.h.

Referenced by updateFiles(), and warmUpFSEvents().

◆ waitForStop

QWaitCondition QFSEventsFileSystemWatcherEngine::waitForStop
private

Definition at line 119 of file qfilesystemwatcher_fsevents_p.h.

Referenced by run(), and stop().


The documentation for this class was generated from the following files: