diff --git a/src/collection/collection.cpp b/src/collection/collection.cpp index 3812959f..9ba6b7c1 100644 --- a/src/collection/collection.cpp +++ b/src/collection/collection.cpp @@ -45,7 +45,6 @@ #include "scrobbler/lastfmimport.h" #include "settings/collectionsettingspage.h" -using std::make_unique; using std::make_shared; const char *SCollection::kSongsTable = "songs"; @@ -93,14 +92,14 @@ SCollection::~SCollection() { void SCollection::Init() { - watcher_ = make_unique(Song::Source::Collection); + watcher_ = new CollectionWatcher(Song::Source::Collection); watcher_thread_ = new Thread(this); watcher_thread_->SetIoPriority(Utilities::IoPriority::IOPRIO_CLASS_IDLE); watcher_->moveToThread(watcher_thread_); - qLog(Debug) << &*watcher_ << "moved to thread" << watcher_thread_; + qLog(Debug) << watcher_ << "moved to thread" << watcher_thread_; watcher_thread_->start(QThread::IdlePriority); @@ -108,20 +107,20 @@ void SCollection::Init() { watcher_->set_task_manager(app_->task_manager()); QObject::connect(&*backend_, &CollectionBackend::Error, this, &SCollection::Error); - QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, &*watcher_, &CollectionWatcher::AddDirectory); - QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, &*watcher_, &CollectionWatcher::RemoveDirectory); + QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory); + QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory); QObject::connect(&*backend_, &CollectionBackend::SongsRatingChanged, this, &SCollection::SongsRatingChanged); QObject::connect(&*backend_, &CollectionBackend::SongsStatisticsChanged, this, &SCollection::SongsPlaycountChanged); - QObject::connect(&*watcher_, &CollectionWatcher::NewOrUpdatedSongs, &*backend_, &CollectionBackend::AddOrUpdateSongs); - QObject::connect(&*watcher_, &CollectionWatcher::SongsMTimeUpdated, &*backend_, &CollectionBackend::UpdateMTimesOnly); - QObject::connect(&*watcher_, &CollectionWatcher::SongsDeleted, &*backend_, &CollectionBackend::DeleteSongs); - QObject::connect(&*watcher_, &CollectionWatcher::SongsUnavailable, &*backend_, &CollectionBackend::MarkSongsUnavailable); - QObject::connect(&*watcher_, &CollectionWatcher::SongsReadded, &*backend_, &CollectionBackend::MarkSongsUnavailable); - QObject::connect(&*watcher_, &CollectionWatcher::SubdirsDiscovered, &*backend_, &CollectionBackend::AddOrUpdateSubdirs); - QObject::connect(&*watcher_, &CollectionWatcher::SubdirsMTimeUpdated, &*backend_, &CollectionBackend::AddOrUpdateSubdirs); - QObject::connect(&*watcher_, &CollectionWatcher::CompilationsNeedUpdating, &*backend_, &CollectionBackend::CompilationsNeedUpdating); - QObject::connect(&*watcher_, &CollectionWatcher::UpdateLastSeen, &*backend_, &CollectionBackend::UpdateLastSeen); + QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, &*backend_, &CollectionBackend::AddOrUpdateSongs); + QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, &*backend_, &CollectionBackend::UpdateMTimesOnly); + QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, &*backend_, &CollectionBackend::DeleteSongs); + QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, &*backend_, &CollectionBackend::MarkSongsUnavailable); + QObject::connect(watcher_, &CollectionWatcher::SongsReadded, &*backend_, &CollectionBackend::MarkSongsUnavailable); + QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, &*backend_, &CollectionBackend::AddOrUpdateSubdirs); + QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, &*backend_, &CollectionBackend::AddOrUpdateSubdirs); + QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, &*backend_, &CollectionBackend::CompilationsNeedUpdating); + QObject::connect(watcher_, &CollectionWatcher::UpdateLastSeen, &*backend_, &CollectionBackend::UpdateLastSeen); QObject::connect(&*app_->lastfm_import(), &LastFMImport::UpdateLastPlayed, &*backend_, &CollectionBackend::UpdateLastPlayed); QObject::connect(&*app_->lastfm_import(), &LastFMImport::UpdatePlayCount, &*backend_, &CollectionBackend::UpdatePlayCount); @@ -133,13 +132,13 @@ void SCollection::Init() { void SCollection::Exit() { - wait_for_exit_ << &*backend_ << &*watcher_; + wait_for_exit_ << &*backend_ << watcher_; - QObject::disconnect(&*backend_, nullptr, &*watcher_, nullptr); - QObject::disconnect(&*watcher_, nullptr, &*backend_, nullptr); + QObject::disconnect(&*backend_, nullptr, watcher_, nullptr); + QObject::disconnect(watcher_, nullptr, &*backend_, nullptr); QObject::connect(&*backend_, &CollectionBackend::ExitFinished, this, &SCollection::ExitReceived); - QObject::connect(&*watcher_, &CollectionWatcher::ExitFinished, this, &SCollection::ExitReceived); + QObject::connect(watcher_, &CollectionWatcher::ExitFinished, this, &SCollection::ExitReceived); backend_->ExitAsync(); watcher_->Abort(); watcher_->ExitAsync(); diff --git a/src/collection/collection.h b/src/collection/collection.h index e6af1ed5..53b3dd72 100644 --- a/src/collection/collection.h +++ b/src/collection/collection.h @@ -29,7 +29,6 @@ #include #include -#include "core/scoped_ptr.h" #include "core/shared_ptr.h" #include "core/song.h" @@ -91,7 +90,7 @@ class SCollection : public QObject { SharedPtr backend_; CollectionModel *model_; - ScopedPtr watcher_; + CollectionWatcher *watcher_; Thread *watcher_thread_; QThread *original_thread_;