Do AddOrUpdateSongs in database thread

This commit is contained in:
Jonas Kvinge 2020-05-12 18:45:24 +02:00
parent c8d5f03070
commit 2bcad9b637
4 changed files with 10 additions and 4 deletions

View File

@ -411,6 +411,10 @@ void CollectionBackend::AddOrUpdateSubdirs(const SubdirectoryList &subdirs) {
}
void CollectionBackend::AddOrUpdateSongsAsync(const SongList &songs) {
metaObject()->invokeMethod(this, "AddOrUpdateSongs", Qt::QueuedConnection, Q_ARG(SongList, songs));
}
void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
QMutexLocker l(db_->Mutex());

View File

@ -186,6 +186,8 @@ class CollectionBackend : public CollectionBackendInterface {
Song::Source Source() const;
void AddOrUpdateSongsAsync(const SongList &songs);
public slots:
void Exit();
void LoadDirectories();

View File

@ -130,7 +130,7 @@ void InternetSongsView::SongsFinished(const SongList &songs, const QString &erro
service_->songs_collection_backend()->DeleteAll();
ui_->stacked->setCurrentWidget(ui_->internetcollection_page);
ui_->status->clear();
service_->songs_collection_backend()->AddOrUpdateSongs(songs);
service_->songs_collection_backend()->AddOrUpdateSongsAsync(songs);
}
}

View File

@ -231,7 +231,7 @@ void InternetTabsView::ArtistsFinished(const SongList &songs, const QString &err
service_->artists_collection_backend()->DeleteAll();
ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->internetcollection_page());
ui_->artists_collection->status()->clear();
service_->artists_collection_backend()->AddOrUpdateSongs(songs);
service_->artists_collection_backend()->AddOrUpdateSongsAsync(songs);
}
}
@ -274,7 +274,7 @@ void InternetTabsView::AlbumsFinished(const SongList &songs, const QString &erro
service_->albums_collection_backend()->DeleteAll();
ui_->albums_collection->stacked()->setCurrentWidget(ui_->albums_collection->internetcollection_page());
ui_->albums_collection->status()->clear();
service_->albums_collection_backend()->AddOrUpdateSongs(songs);
service_->albums_collection_backend()->AddOrUpdateSongsAsync(songs);
}
}
@ -317,7 +317,7 @@ void InternetTabsView::SongsFinished(const SongList &songs, const QString &error
service_->songs_collection_backend()->DeleteAll();
ui_->songs_collection->stacked()->setCurrentWidget(ui_->songs_collection->internetcollection_page());
ui_->songs_collection->status()->clear();
service_->songs_collection_backend()->AddOrUpdateSongs(songs);
service_->songs_collection_backend()->AddOrUpdateSongsAsync(songs);
}
}