1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 12:02:48 +01:00

Disable watching for FS updates when requested.

(cherry picked from commit 55e9fd8dc3)
This commit is contained in:
John Maguire 2012-01-05 15:01:43 +00:00 committed by David Sansome
parent ec2f57148b
commit b5ff9955a8
6 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,7 @@ class FileSystemWatcherInterface : public QObject {
FileSystemWatcherInterface(QObject* parent = 0);
virtual void Init() {}
virtual void AddPath(const QString& path) = 0;
virtual void Clear() = 0;
static FileSystemWatcherInterface* Create(QObject* parent = 0);

View File

@ -14,8 +14,8 @@ class MacFSListener : public FileSystemWatcherInterface {
public:
explicit MacFSListener(QObject* parent = 0);
void Init();
void AddPath(const QString& path);
void Clear();
signals:
void PathChanged(const QString& path);

View File

@ -39,6 +39,11 @@ void MacFSListener::AddPath(const QString& path) {
UpdateStream();
}
void MacFSListener::Clear() {
paths_.clear();
UpdateStream();
}
void MacFSListener::UpdateStream() {
if (stream_) {
FSEventStreamStop(stream_);

View File

@ -1,5 +1,7 @@
#include "qtfslistener.h"
#include <QStringList>
QtFSListener::QtFSListener(QObject* parent)
: FileSystemWatcherInterface(parent),
watcher_(this) {
@ -10,3 +12,8 @@ QtFSListener::QtFSListener(QObject* parent)
void QtFSListener::AddPath(const QString& path) {
watcher_.addPath(path);
}
void QtFSListener::Clear() {
watcher_.removePaths(watcher_.directories());
watcher_.removePaths(watcher_.files());
}

View File

@ -10,6 +10,7 @@ class QtFSListener : public FileSystemWatcherInterface {
public:
QtFSListener(QObject* parent);
virtual void AddPath(const QString& path);
virtual void Clear();
private:
QFileSystemWatcher watcher_;

View File

@ -694,7 +694,7 @@ void LibraryWatcher::ReloadSettings() {
}
if (!monitor_ && was_monitoring_before) {
// TODO: Remove all directories from watcher.
fs_watcher_->Clear();
} else if (monitor_ && !was_monitoring_before) {
// Add all directories to all QFileSystemWatchers again
foreach (const DirData& data, watched_dirs_.values()) {