Fix macOS filesystem listener (library watcher)

This commit is contained in:
Jonas Kvinge 2020-01-04 17:38:55 +01:00
parent 0308a3f9a5
commit 30413767cb
2 changed files with 10 additions and 7 deletions

View File

@ -24,10 +24,11 @@
#include <QObject>
#include <QSet>
#include <QTimer>
#include "filesystemwatcherinterface.h"
class QTimer;
class MacFSListener : public FileSystemWatcherInterface {
Q_OBJECT
@ -56,7 +57,7 @@ class MacFSListener : public FileSystemWatcherInterface {
FSEventStreamRef stream_;
QSet<QString> paths_;
QTimer update_timer_;
QTimer *update_timer_;
};
#endif // CORE_MACFSLISTENER_H_

View File

@ -22,14 +22,16 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSString.h>
#include <QTimer>
#include "core/logging.h"
#include "core/scoped_nsobject.h"
MacFSListener::MacFSListener(QObject* parent)
: FileSystemWatcherInterface(parent), run_loop_(nullptr), stream_(nullptr) {
update_timer_.setSingleShot(true);
update_timer_.setInterval(2000);
connect(&update_timer_, SIGNAL(timeout()), SLOT(UpdateStream()));
: FileSystemWatcherInterface(parent), run_loop_(nullptr), stream_(nullptr), update_timer_(new QTimer(this)) {
update_timer_->setSingleShot(true);
update_timer_->setInterval(2000);
connect(update_timer_, SIGNAL(timeout()), SLOT(UpdateStream()));
}
void MacFSListener::Init() { run_loop_ = CFRunLoopGetCurrent(); }
@ -67,7 +69,7 @@ void MacFSListener::Clear() {
UpdateStreamAsync();
}
void MacFSListener::UpdateStreamAsync() { update_timer_.start(); }
void MacFSListener::UpdateStreamAsync() { update_timer_->start(); }
void MacFSListener::UpdateStream() {
if (stream_) {