mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-09 08:18:49 +01:00
Fix crash in internet services
This commit is contained in:
parent
be1e14df81
commit
c6e08e0039
@ -47,16 +47,7 @@ QobuzBaseRequest::QobuzBaseRequest(QobuzService *service, NetworkAccessManager *
|
||||
network_(network)
|
||||
{}
|
||||
|
||||
QobuzBaseRequest::~QobuzBaseRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
}
|
||||
QobuzBaseRequest::~QobuzBaseRequest() {}
|
||||
|
||||
QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, const QList<Param> ¶ms_provided) {
|
||||
|
||||
@ -78,7 +69,6 @@ QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, co
|
||||
|
||||
QNetworkReply *reply = network_->get(req);
|
||||
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(HandleSSLErrors(QList<QSslError>)));
|
||||
replies_ << reply;
|
||||
|
||||
//qLog(Debug) << "Qobuz: Sending request" << url;
|
||||
|
||||
@ -96,11 +86,6 @@ void QobuzBaseRequest::HandleSSLErrors(QList<QSslError> ssl_errors) {
|
||||
|
||||
QByteArray QobuzBaseRequest::GetReplyData(QNetworkReply *reply) {
|
||||
|
||||
if (replies_.contains(reply)) {
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) {
|
||||
|
@ -105,7 +105,6 @@ class QobuzBaseRequest : public QObject {
|
||||
|
||||
QobuzService *service_;
|
||||
NetworkAccessManager *network_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -72,7 +72,7 @@ class QobuzFavoriteRequest : public QobuzBaseRequest {
|
||||
|
||||
QobuzService *service_;
|
||||
NetworkAccessManager *network_;
|
||||
QList <QNetworkReply*> replies_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -75,6 +75,13 @@ QobuzRequest::QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler,
|
||||
|
||||
QobuzRequest::~QobuzRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
while (!album_cover_replies_.isEmpty()) {
|
||||
QNetworkReply *reply = album_cover_replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
@ -158,6 +165,7 @@ void QobuzRequest::FlushArtistsRequests() {
|
||||
reply = CreateRequest("artist/search", params);
|
||||
}
|
||||
if (!reply) continue;
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(ArtistsReplyReceived(QNetworkReply*, const int, const int)), reply, request.limit, request.offset);
|
||||
|
||||
}
|
||||
@ -205,6 +213,7 @@ void QobuzRequest::FlushAlbumsRequests() {
|
||||
reply = CreateRequest("album/search", params);
|
||||
}
|
||||
if (!reply) continue;
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumsReplyReceived(QNetworkReply*, const int, const int)), reply, request.limit, request.offset);
|
||||
|
||||
}
|
||||
@ -252,6 +261,7 @@ void QobuzRequest::FlushSongsRequests() {
|
||||
reply = CreateRequest("track/search", params);
|
||||
}
|
||||
if (!reply) continue;
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(SongsReplyReceived(QNetworkReply*, const int, const int)), reply, request.limit, request.offset);
|
||||
|
||||
}
|
||||
@ -302,6 +312,10 @@ void QobuzRequest::AddSongsSearchRequest(const int offset) {
|
||||
|
||||
void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
|
||||
--artists_requests_active_;
|
||||
@ -479,6 +493,7 @@ void QobuzRequest::FlushArtistAlbumsRequests() {
|
||||
|
||||
if (request.offset > 0) params << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = CreateRequest(QString("artist/get"), params);
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(ArtistAlbumsReplyReceived(QNetworkReply*, const qint64, const int)), reply, request.artist_id, request.offset);
|
||||
|
||||
}
|
||||
@ -497,6 +512,10 @@ void QobuzRequest::ArtistAlbumsReplyReceived(QNetworkReply *reply, const qint64
|
||||
|
||||
void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const qint64 artist_id_requested, const int limit_requested, const int offset_requested) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
|
||||
if (finished_) return;
|
||||
@ -707,6 +726,7 @@ void QobuzRequest::FlushAlbumSongsRequests() {
|
||||
ParamList params = ParamList() << Param("album_id", request.album_id);
|
||||
if (request.offset > 0) params << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = CreateRequest(QString("album/get"), params);
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumSongsReplyReceived(QNetworkReply*, const qint64, const QString&, const int, const QString&, const QString&)), reply, request.artist_id, request.album_id, request.offset, request.album_artist, request.album);
|
||||
|
||||
}
|
||||
@ -726,6 +746,10 @@ void QobuzRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const qint64 ar
|
||||
|
||||
void QobuzRequest::SongsReceived(QNetworkReply *reply, const qint64 artist_id_requested, const QString &album_id_requested, const int limit_requested, const int offset_requested, const QString &album_artist_requested, const QString &album_requested) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
|
||||
if (finished_) return;
|
||||
|
@ -198,6 +198,7 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
SongList songs_;
|
||||
QStringList errors_;
|
||||
bool no_results_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
QList<QNetworkReply*> album_cover_replies_;
|
||||
|
||||
};
|
||||
|
@ -46,16 +46,7 @@ SubsonicBaseRequest::SubsonicBaseRequest(SubsonicService *service, NetworkAccess
|
||||
network_(network)
|
||||
{}
|
||||
|
||||
SubsonicBaseRequest::~SubsonicBaseRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
}
|
||||
SubsonicBaseRequest::~SubsonicBaseRequest() {}
|
||||
|
||||
QUrl SubsonicBaseRequest::CreateUrl(const QString &ressource_name, const QList<Param> ¶ms_provided) {
|
||||
|
||||
@ -101,7 +92,6 @@ QNetworkReply *SubsonicBaseRequest::CreateGetRequest(const QString &ressource_na
|
||||
|
||||
QNetworkReply *reply = network_->get(req);
|
||||
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(HandleSSLErrors(QList<QSslError>)));
|
||||
replies_ << reply;
|
||||
|
||||
//qLog(Debug) << "Subsonic: Sending request" << url;
|
||||
|
||||
@ -119,11 +109,6 @@ void SubsonicBaseRequest::HandleSSLErrors(QList<QSslError> ssl_errors) {
|
||||
|
||||
QByteArray SubsonicBaseRequest::GetReplyData(QNetworkReply *reply) {
|
||||
|
||||
if (replies_.contains(reply)) {
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) {
|
||||
|
@ -81,7 +81,6 @@ class SubsonicBaseRequest : public QObject {
|
||||
|
||||
SubsonicService *service_;
|
||||
NetworkAccessManager *network_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -69,6 +69,13 @@ SubsonicRequest::SubsonicRequest(SubsonicService *service, SubsonicUrlHandler *u
|
||||
|
||||
SubsonicRequest::~SubsonicRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
while (!album_cover_replies_.isEmpty()) {
|
||||
QNetworkReply *reply = album_cover_replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
@ -99,6 +106,7 @@ void SubsonicRequest::Reset() {
|
||||
songs_.clear();
|
||||
errors_.clear();
|
||||
no_results_ = false;
|
||||
replies_.clear();
|
||||
album_cover_replies_.clear();
|
||||
|
||||
}
|
||||
@ -134,6 +142,7 @@ void SubsonicRequest::FlushAlbumsRequests() {
|
||||
|
||||
QNetworkReply *reply;
|
||||
reply = CreateGetRequest(QString("getAlbumList2"), params);
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumsReplyReceived(QNetworkReply*, int)), reply, request.offset);
|
||||
|
||||
}
|
||||
@ -142,6 +151,10 @@ void SubsonicRequest::FlushAlbumsRequests() {
|
||||
|
||||
void SubsonicRequest::AlbumsReplyReceived(QNetworkReply *reply, const int offset_requested) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
--albums_requests_active_;
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
@ -318,6 +331,7 @@ void SubsonicRequest::FlushAlbumSongsRequests() {
|
||||
++album_songs_requests_active_;
|
||||
ParamList params = ParamList() << Param("id", QString::number(request.album_id));
|
||||
QNetworkReply *reply = CreateGetRequest(QString("getAlbum"), params);
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumSongsReplyReceived(QNetworkReply*, const qint64, const qint64, const QString&)), reply, request.artist_id, request.album_id, request.album_artist);
|
||||
|
||||
}
|
||||
@ -326,6 +340,10 @@ void SubsonicRequest::FlushAlbumSongsRequests() {
|
||||
|
||||
void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const qint64 artist_id, const qint64 album_id, const QString &album_artist) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
--album_songs_requests_active_;
|
||||
++album_songs_received_;
|
||||
|
||||
@ -719,4 +737,3 @@ void SubsonicRequest::Warn(const QString &error, const QVariant &debug) {
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
|
||||
}
|
||||
|
||||
|
@ -138,6 +138,7 @@ class SubsonicRequest : public SubsonicBaseRequest {
|
||||
SongList songs_;
|
||||
QStringList errors_;
|
||||
bool no_results_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
QList<QNetworkReply*> album_cover_replies_;
|
||||
|
||||
};
|
||||
|
@ -48,16 +48,7 @@ TidalBaseRequest::TidalBaseRequest(TidalService *service, NetworkAccessManager *
|
||||
network_(network)
|
||||
{}
|
||||
|
||||
TidalBaseRequest::~TidalBaseRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
}
|
||||
TidalBaseRequest::~TidalBaseRequest() {}
|
||||
|
||||
QNetworkReply *TidalBaseRequest::CreateRequest(const QString &ressource_name, const QList<Param> ¶ms_provided) {
|
||||
|
||||
@ -79,7 +70,6 @@ QNetworkReply *TidalBaseRequest::CreateRequest(const QString &ressource_name, co
|
||||
|
||||
QNetworkReply *reply = network_->get(req);
|
||||
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(HandleSSLErrors(QList<QSslError>)));
|
||||
replies_ << reply;
|
||||
|
||||
//qLog(Debug) << "Tidal: Sending request" << url;
|
||||
|
||||
@ -97,11 +87,6 @@ void TidalBaseRequest::HandleSSLErrors(QList<QSslError> ssl_errors) {
|
||||
|
||||
QByteArray TidalBaseRequest::GetReplyData(QNetworkReply *reply, const bool send_login) {
|
||||
|
||||
if (replies_.contains(reply)) {
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) {
|
||||
|
@ -112,7 +112,6 @@ class TidalBaseRequest : public QObject {
|
||||
|
||||
TidalService *service_;
|
||||
NetworkAccessManager *network_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -78,6 +78,13 @@ TidalRequest::TidalRequest(TidalService *service, TidalUrlHandler *url_handler,
|
||||
|
||||
TidalRequest::~TidalRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
while (!album_cover_replies_.isEmpty()) {
|
||||
QNetworkReply *reply = album_cover_replies_.takeFirst();
|
||||
disconnect(reply, 0, this, 0);
|
||||
@ -177,6 +184,8 @@ void TidalRequest::FlushArtistsRequests() {
|
||||
if (type_ == QueryType_SearchArtists) {
|
||||
reply = CreateRequest("search/artists", parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(ArtistsReplyReceived(QNetworkReply*, const int, const int)), reply, request.limit, request.offset);
|
||||
|
||||
}
|
||||
@ -219,6 +228,8 @@ void TidalRequest::FlushAlbumsRequests() {
|
||||
if (type_ == QueryType_SearchAlbums) {
|
||||
reply = CreateRequest("search/albums", parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumsReplyReceived(QNetworkReply*, const int, const int)), reply, request.limit, request.offset);
|
||||
|
||||
}
|
||||
@ -261,6 +272,8 @@ void TidalRequest::FlushSongsRequests() {
|
||||
if (type_ == QueryType_SearchSongs) {
|
||||
reply = CreateRequest("search/tracks", parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(SongsReplyReceived(QNetworkReply*, const int, const int)), reply, request.limit, request.offset);
|
||||
|
||||
}
|
||||
@ -311,6 +324,10 @@ void TidalRequest::AddSongsSearchRequest(const int offset) {
|
||||
|
||||
void TidalRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply, (offset_requested == 0));
|
||||
|
||||
--artists_requests_active_;
|
||||
@ -474,6 +491,7 @@ void TidalRequest::FlushArtistAlbumsRequests() {
|
||||
if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = CreateRequest(QString("artists/%1/albums").arg(request.artist_id), parameters);
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(ArtistAlbumsReplyReceived(QNetworkReply*, const qint64, const int)), reply, request.artist_id, request.offset);
|
||||
replies_ << reply;
|
||||
|
||||
}
|
||||
|
||||
@ -491,6 +509,10 @@ void TidalRequest::ArtistAlbumsReplyReceived(QNetworkReply *reply, const qint64
|
||||
|
||||
void TidalRequest::AlbumsReceived(QNetworkReply *reply, const qint64 artist_id_requested, const int limit_requested, const int offset_requested, const bool auto_login) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply, auto_login);
|
||||
|
||||
if (finished_) return;
|
||||
@ -717,6 +739,7 @@ void TidalRequest::FlushAlbumSongsRequests() {
|
||||
ParamList parameters;
|
||||
if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = CreateRequest(QString("albums/%1/tracks").arg(request.album_id), parameters);
|
||||
replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumSongsReplyReceived(QNetworkReply*, const qint64, const qint64, const int, const QString&)), reply, request.artist_id, request.album_id, request.offset, request.album_artist);
|
||||
|
||||
}
|
||||
@ -736,6 +759,10 @@ void TidalRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const qint64 ar
|
||||
|
||||
void TidalRequest::SongsReceived(QNetworkReply *reply, const qint64 artist_id, const qint64 album_id, const int limit_requested, const int offset_requested, const bool auto_login, const QString &album_artist) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply, auto_login);
|
||||
|
||||
if (finished_) return;
|
||||
|
@ -203,6 +203,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
QStringList errors_;
|
||||
bool need_login_;
|
||||
bool no_results_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
QList<QNetworkReply*> album_cover_replies_;
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user