mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 20:09:50 +01:00
Disable watching for FS updates when requested.
(cherry picked from commit 55e9fd8dc3
)
This commit is contained in:
parent
ec2f57148b
commit
b5ff9955a8
@ -9,6 +9,7 @@ class FileSystemWatcherInterface : public QObject {
|
|||||||
FileSystemWatcherInterface(QObject* parent = 0);
|
FileSystemWatcherInterface(QObject* parent = 0);
|
||||||
virtual void Init() {}
|
virtual void Init() {}
|
||||||
virtual void AddPath(const QString& path) = 0;
|
virtual void AddPath(const QString& path) = 0;
|
||||||
|
virtual void Clear() = 0;
|
||||||
|
|
||||||
static FileSystemWatcherInterface* Create(QObject* parent = 0);
|
static FileSystemWatcherInterface* Create(QObject* parent = 0);
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ class MacFSListener : public FileSystemWatcherInterface {
|
|||||||
public:
|
public:
|
||||||
explicit MacFSListener(QObject* parent = 0);
|
explicit MacFSListener(QObject* parent = 0);
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
void AddPath(const QString& path);
|
void AddPath(const QString& path);
|
||||||
|
void Clear();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void PathChanged(const QString& path);
|
void PathChanged(const QString& path);
|
||||||
|
@ -39,6 +39,11 @@ void MacFSListener::AddPath(const QString& path) {
|
|||||||
UpdateStream();
|
UpdateStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacFSListener::Clear() {
|
||||||
|
paths_.clear();
|
||||||
|
UpdateStream();
|
||||||
|
}
|
||||||
|
|
||||||
void MacFSListener::UpdateStream() {
|
void MacFSListener::UpdateStream() {
|
||||||
if (stream_) {
|
if (stream_) {
|
||||||
FSEventStreamStop(stream_);
|
FSEventStreamStop(stream_);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "qtfslistener.h"
|
#include "qtfslistener.h"
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
QtFSListener::QtFSListener(QObject* parent)
|
QtFSListener::QtFSListener(QObject* parent)
|
||||||
: FileSystemWatcherInterface(parent),
|
: FileSystemWatcherInterface(parent),
|
||||||
watcher_(this) {
|
watcher_(this) {
|
||||||
@ -10,3 +12,8 @@ QtFSListener::QtFSListener(QObject* parent)
|
|||||||
void QtFSListener::AddPath(const QString& path) {
|
void QtFSListener::AddPath(const QString& path) {
|
||||||
watcher_.addPath(path);
|
watcher_.addPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtFSListener::Clear() {
|
||||||
|
watcher_.removePaths(watcher_.directories());
|
||||||
|
watcher_.removePaths(watcher_.files());
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ class QtFSListener : public FileSystemWatcherInterface {
|
|||||||
public:
|
public:
|
||||||
QtFSListener(QObject* parent);
|
QtFSListener(QObject* parent);
|
||||||
virtual void AddPath(const QString& path);
|
virtual void AddPath(const QString& path);
|
||||||
|
virtual void Clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFileSystemWatcher watcher_;
|
QFileSystemWatcher watcher_;
|
||||||
|
@ -694,7 +694,7 @@ void LibraryWatcher::ReloadSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!monitor_ && was_monitoring_before) {
|
if (!monitor_ && was_monitoring_before) {
|
||||||
// TODO: Remove all directories from watcher.
|
fs_watcher_->Clear();
|
||||||
} else if (monitor_ && !was_monitoring_before) {
|
} else if (monitor_ && !was_monitoring_before) {
|
||||||
// Add all directories to all QFileSystemWatchers again
|
// Add all directories to all QFileSystemWatchers again
|
||||||
foreach (const DirData& data, watched_dirs_.values()) {
|
foreach (const DirData& data, watched_dirs_.values()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user