mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Cancel network requests and outstanding fingerprint operations when cancelling musicbrainz lookups
This commit is contained in:
parent
e2cd6d02ee
commit
8690438ad4
@ -48,10 +48,13 @@ void MusicBrainzClient::Start(int id, const QString& puid) {
|
||||
}
|
||||
|
||||
void MusicBrainzClient::Cancel(int id) {
|
||||
requests_.remove(requests_.key(id));
|
||||
QNetworkReply* reply = requests_.key(id);
|
||||
requests_.remove(reply);
|
||||
delete reply;
|
||||
}
|
||||
|
||||
void MusicBrainzClient::CancelAll() {
|
||||
qDeleteAll(requests_.keys());
|
||||
requests_.clear();
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,13 @@ void MusicDnsClient::Start(int id, const QString& fingerprint, int duration_msec
|
||||
}
|
||||
|
||||
void MusicDnsClient::Cancel(int id) {
|
||||
requests_.remove(requests_.key(id));
|
||||
QNetworkReply* reply = requests_.key(id);
|
||||
requests_.remove(reply);
|
||||
delete reply;
|
||||
}
|
||||
|
||||
void MusicDnsClient::CancelAll() {
|
||||
qDeleteAll(requests_.keys());
|
||||
requests_.clear();
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@ QString TagFetcher::GetFingerprint(const Song& song) {
|
||||
}
|
||||
|
||||
void TagFetcher::StartFetch(const SongList& songs) {
|
||||
Cancel();
|
||||
|
||||
songs_ = songs;
|
||||
|
||||
QFuture<QString> future = QtConcurrent::mapped(songs_, GetFingerprint);
|
||||
@ -52,11 +54,16 @@ void TagFetcher::StartFetch(const SongList& songs) {
|
||||
}
|
||||
|
||||
void TagFetcher::Cancel() {
|
||||
delete fingerprint_watcher_;
|
||||
fingerprint_watcher_ = NULL;
|
||||
if (fingerprint_watcher_) {
|
||||
fingerprint_watcher_->cancel();
|
||||
|
||||
delete fingerprint_watcher_;
|
||||
fingerprint_watcher_ = NULL;
|
||||
}
|
||||
|
||||
musicdns_client_->CancelAll();
|
||||
musicbrainz_client_->CancelAll();
|
||||
songs_.clear();
|
||||
}
|
||||
|
||||
void TagFetcher::FingerprintFound(int index) {
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
TagFetcher(QObject* parent = 0);
|
||||
|
||||
void StartFetch(const SongList& songs);
|
||||
|
||||
public slots:
|
||||
void Cancel();
|
||||
|
||||
signals:
|
||||
|
@ -66,6 +66,7 @@ EditTagDialog::EditTagDialog(QWidget* parent)
|
||||
results_dialog_, SLOT(FetchTagProgress(Song,QString)));
|
||||
connect(results_dialog_, SIGNAL(SongChosen(Song, Song)),
|
||||
SLOT(FetchTagSongChosen(Song, Song)));
|
||||
connect(results_dialog_, SIGNAL(finished(int)), tag_fetcher_, SLOT(Cancel()));
|
||||
|
||||
ui_->setupUi(this);
|
||||
ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
|
||||
|
@ -1906,6 +1906,8 @@ void MainWindow::AutoCompleteTags() {
|
||||
track_selection_dialog_.get(), SLOT(FetchTagProgress(Song,QString)));
|
||||
connect(track_selection_dialog_.get(), SIGNAL(accepted()),
|
||||
SLOT(AutoCompleteTagsAccepted()));
|
||||
connect(track_selection_dialog_.get(), SIGNAL(finished(int)),
|
||||
tag_fetcher_.get(), SLOT(Cancel()));
|
||||
}
|
||||
|
||||
// Get the selected songs and start fetching tags for them
|
||||
|
Loading…
x
Reference in New Issue
Block a user