Never use reference when iterating QJsonArray
This commit is contained in:
@@ -223,7 +223,7 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
|||||||
|
|
||||||
QMap<QUrl, CoverSearchResult> results;
|
QMap<QUrl, CoverSearchResult> results;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const QJsonValue &json_value : array_data) {
|
for (const QJsonValue json_value : array_data) {
|
||||||
|
|
||||||
if (!json_value.isObject()) {
|
if (!json_value.isObject()) {
|
||||||
Error("Invalid Json reply, data array value is not a object.", json_value);
|
Error("Invalid Json reply, data array value is not a object.", json_value);
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
|||||||
array_results = value_results.toArray();
|
array_results = value_results.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QJsonValue &value_result : array_results) {
|
for (const QJsonValue value_result : array_results) {
|
||||||
|
|
||||||
if (!value_result.isObject()) {
|
if (!value_result.isObject()) {
|
||||||
Error("Invalid Json reply, results value is not a object.", value_result);
|
Error("Invalid Json reply, results value is not a object.", value_result);
|
||||||
@@ -380,7 +380,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
|||||||
QJsonArray array_artists = value_artists.toArray();
|
QJsonArray array_artists = value_artists.toArray();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QString artist;
|
QString artist;
|
||||||
for (const QJsonValue &value_artist : array_artists) {
|
for (const QJsonValue value_artist : array_artists) {
|
||||||
if (!value_artist.isObject()) {
|
if (!value_artist.isObject()) {
|
||||||
Error("Invalid Json reply, atists array value is not a object.", value_artist);
|
Error("Invalid Json reply, atists array value is not a object.", value_artist);
|
||||||
continue;
|
continue;
|
||||||
@@ -421,7 +421,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QJsonValue &value_image : array_images) {
|
for (const QJsonValue value_image : array_images) {
|
||||||
|
|
||||||
if (!value_image.isObject()) {
|
if (!value_image.isObject()) {
|
||||||
Error("Invalid Json reply, images array value is not an object.", value_image);
|
Error("Invalid Json reply, images array value is not an object.", value_image);
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
|||||||
}
|
}
|
||||||
QJsonArray array_type = value_type.toArray();
|
QJsonArray array_type = value_type.toArray();
|
||||||
|
|
||||||
for (const QJsonValue &value : array_type) {
|
for (const QJsonValue value : array_type) {
|
||||||
|
|
||||||
if (!value.isObject()) {
|
if (!value.isObject()) {
|
||||||
Error("Invalid Json reply, value in albummatches/trackmatches array is not a object.", value);
|
Error("Invalid Json reply, value in albummatches/trackmatches array is not a object.", value);
|
||||||
@@ -255,7 +255,7 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
|||||||
QJsonArray array_image = json_image.toArray();
|
QJsonArray array_image = json_image.toArray();
|
||||||
QUrl url;
|
QUrl url;
|
||||||
LastFmImageSize size(LastFmImageSize::Unknown);
|
LastFmImageSize size(LastFmImageSize::Unknown);
|
||||||
for (const QJsonValue &value_image : array_image) {
|
for (const QJsonValue value_image : array_image) {
|
||||||
if (!value_image.isObject()) {
|
if (!value_image.isObject()) {
|
||||||
Error("Invalid Json reply, album image value is not an object.", value_image);
|
Error("Invalid Json reply, album image value is not an object.", value_image);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QJsonValue &value_release : array_releases) {
|
for (const QJsonValue value_release : array_releases) {
|
||||||
|
|
||||||
if (!value_release.isObject()) {
|
if (!value_release.isObject()) {
|
||||||
Error("Invalid Json reply, releases array value is not an object.", value_release);
|
Error("Invalid Json reply, releases array value is not an object.", value_release);
|
||||||
@@ -187,7 +187,7 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
|||||||
QJsonArray array_artists = json_artists.toArray();
|
QJsonArray array_artists = json_artists.toArray();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QString artist;
|
QString artist;
|
||||||
for (const QJsonValue &value_artist : array_artists) {
|
for (const QJsonValue value_artist : array_artists) {
|
||||||
if (!value_artist.isObject()) {
|
if (!value_artist.isObject()) {
|
||||||
Error("Invalid Json reply, artist is not a object.", value_artist);
|
Error("Invalid Json reply, artist is not a object.", value_artist);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ void QobuzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
|||||||
}
|
}
|
||||||
QJsonArray array_items = value_items.toArray();
|
QJsonArray array_items = value_items.toArray();
|
||||||
|
|
||||||
for (const QJsonValue &value : array_items) {
|
for (const QJsonValue value : array_items) {
|
||||||
|
|
||||||
if (!value.isObject()) {
|
if (!value.isObject()) {
|
||||||
Error("Invalid Json reply, value in items is not a object.", value);
|
Error("Invalid Json reply, value in items is not a object.", value);
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoverSearchResults results;
|
CoverSearchResults results;
|
||||||
for (const QJsonValue &value_item : array_items) {
|
for (const QJsonValue value_item : array_items) {
|
||||||
|
|
||||||
if (!value_item.isObject()) {
|
if (!value_item.isObject()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -516,14 +516,14 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
|
|||||||
QString album = obj_album["name"].toString();
|
QString album = obj_album["name"].toString();
|
||||||
|
|
||||||
QStringList artists;
|
QStringList artists;
|
||||||
for (const QJsonValue &value_artist : array_artists) {
|
for (const QJsonValue value_artist : array_artists) {
|
||||||
if (!value_artist.isObject()) continue;
|
if (!value_artist.isObject()) continue;
|
||||||
QJsonObject obj_artist = value_artist.toObject();
|
QJsonObject obj_artist = value_artist.toObject();
|
||||||
if (!obj_artist.contains("name")) continue;
|
if (!obj_artist.contains("name")) continue;
|
||||||
artists << obj_artist["name"].toString();
|
artists << obj_artist["name"].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QJsonValue &value_image : array_images) {
|
for (const QJsonValue value_image : array_images) {
|
||||||
if (!value_image.isObject()) continue;
|
if (!value_image.isObject()) continue;
|
||||||
QJsonObject obj_image = value_image.toObject();
|
QJsonObject obj_image = value_image.toObject();
|
||||||
if (!obj_image.contains("url") || !obj_image.contains("width") || !obj_image.contains("height")) continue;
|
if (!obj_image.contains("url") || !obj_image.contains("width") || !obj_image.contains("height")) continue;
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
|||||||
|
|
||||||
CoverSearchResults results;
|
CoverSearchResults results;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const QJsonValue &value_item : array_items) {
|
for (const QJsonValue value_item : array_items) {
|
||||||
|
|
||||||
if (!value_item.isObject()) {
|
if (!value_item.isObject()) {
|
||||||
Error("Invalid Json reply, items array item is not a object.", value_item);
|
Error("Invalid Json reply, items array item is not a object.", value_item);
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
|
|||||||
}
|
}
|
||||||
|
|
||||||
LyricsSearchResults results;
|
LyricsSearchResults results;
|
||||||
for (const QJsonValue &value : json_result) {
|
for (const QJsonValue value : json_result) {
|
||||||
if (!value.isObject()) {
|
if (!value.isObject()) {
|
||||||
qLog(Error) << "AudDLyrics: Invalid Json reply, result is not an object.";
|
qLog(Error) << "AudDLyrics: Invalid Json reply, result is not an object.";
|
||||||
qLog(Debug) << value;
|
qLog(Debug) << value;
|
||||||
|
|||||||
@@ -167,11 +167,11 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id)
|
|||||||
// List of <id, nb of sources> pairs
|
// List of <id, nb of sources> pairs
|
||||||
QList<IdSource> id_source_list;
|
QList<IdSource> id_source_list;
|
||||||
|
|
||||||
for (const QJsonValue& v : json_results) {
|
for (const QJsonValue v : json_results) {
|
||||||
QJsonObject r = v.toObject();
|
QJsonObject r = v.toObject();
|
||||||
if (!r["recordings"].isUndefined()) {
|
if (!r["recordings"].isUndefined()) {
|
||||||
QJsonArray json_recordings = r["recordings"].toArray();
|
QJsonArray json_recordings = r["recordings"].toArray();
|
||||||
for (const QJsonValue& recording : json_recordings) {
|
for (const QJsonValue recording : json_recordings) {
|
||||||
QJsonObject o = recording.toObject();
|
QJsonObject o = recording.toObject();
|
||||||
if (!o["id"].isUndefined()) {
|
if (!o["id"].isUndefined()) {
|
||||||
id_source_list << IdSource(o["id"].toString(), o["sources"].toInt());
|
id_source_list << IdSource(o["id"].toString(), o["sources"].toInt());
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
|
|||||||
}
|
}
|
||||||
|
|
||||||
int artists_received = 0;
|
int artists_received = 0;
|
||||||
for (const QJsonValue &value_item : array_items) {
|
for (const QJsonValue value_item : array_items) {
|
||||||
|
|
||||||
++artists_received;
|
++artists_received;
|
||||||
|
|
||||||
@@ -609,7 +609,7 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const QString &artist_id
|
|||||||
}
|
}
|
||||||
|
|
||||||
int albums_received = 0;
|
int albums_received = 0;
|
||||||
for (const QJsonValue &value : array_items) {
|
for (const QJsonValue value : array_items) {
|
||||||
|
|
||||||
++albums_received;
|
++albums_received;
|
||||||
|
|
||||||
@@ -907,7 +907,7 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const QString &artist_id_
|
|||||||
//bool multidisc = false;
|
//bool multidisc = false;
|
||||||
SongList songs;
|
SongList songs;
|
||||||
int songs_received = 0;
|
int songs_received = 0;
|
||||||
for (const QJsonValue &value_item : array_items) {
|
for (const QJsonValue value_item : array_items) {
|
||||||
|
|
||||||
if (!value_item.isObject()) {
|
if (!value_item.isObject()) {
|
||||||
Error("Invalid Json reply, track is not a object.", value_item);
|
Error("Invalid Json reply, track is not a object.", value_item);
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in
|
|||||||
|
|
||||||
QJsonArray array_track = json_obj["track"].toArray();
|
QJsonArray array_track = json_obj["track"].toArray();
|
||||||
|
|
||||||
for (const QJsonValue &value_track : array_track) {
|
for (const QJsonValue value_track : array_track) {
|
||||||
|
|
||||||
++lastplayed_received_;
|
++lastplayed_received_;
|
||||||
|
|
||||||
@@ -516,7 +516,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
QJsonArray array_track = json_obj["track"].toArray();
|
QJsonArray array_track = json_obj["track"].toArray();
|
||||||
for (const QJsonValue &value_track : array_track) {
|
for (const QJsonValue value_track : array_track) {
|
||||||
|
|
||||||
++playcount_received_;
|
++playcount_received_;
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ void ScrobblerCache::ReadCache() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QJsonValue &value : json_array) {
|
for (const QJsonValue value : json_array) {
|
||||||
if (!value.isObject()) {
|
if (!value.isObject()) {
|
||||||
qLog(Error) << "Scrobbler cache JSON tracks array value is not an object.";
|
qLog(Error) << "Scrobbler cache JSON tracks array value is not an object.";
|
||||||
qLog(Debug) << value;
|
qLog(Debug) << value;
|
||||||
|
|||||||
@@ -711,7 +711,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QJsonValue &value : array_scrobble) {
|
for (const QJsonValue value : array_scrobble) {
|
||||||
|
|
||||||
if (!value.isObject()) {
|
if (!value.isObject()) {
|
||||||
Error("Json scrobbles scrobble array value is not an object.", value);
|
Error("Json scrobbles scrobble array value is not an object.", value);
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ void SubsonicRequest::AlbumsReplyReceived(QNetworkReply *reply, const int offset
|
|||||||
}
|
}
|
||||||
|
|
||||||
int albums_received = 0;
|
int albums_received = 0;
|
||||||
for (const QJsonValue &value_album : array_albums) {
|
for (const QJsonValue value_album : array_albums) {
|
||||||
|
|
||||||
++albums_received;
|
++albums_received;
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin
|
|||||||
bool multidisc = false;
|
bool multidisc = false;
|
||||||
SongList songs;
|
SongList songs;
|
||||||
int songs_received = 0;
|
int songs_received = 0;
|
||||||
for (const QJsonValue &value_song : array_songs) {
|
for (const QJsonValue value_song : array_songs) {
|
||||||
|
|
||||||
if (!value_song.isObject()) {
|
if (!value_song.isObject()) {
|
||||||
Error("Invalid Json reply, track is not a object.", value_song);
|
Error("Invalid Json reply, track is not a object.", value_song);
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ void TidalRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
|
|||||||
}
|
}
|
||||||
|
|
||||||
int artists_received = 0;
|
int artists_received = 0;
|
||||||
for (const QJsonValue &value_item : array_items) {
|
for (const QJsonValue value_item : array_items) {
|
||||||
|
|
||||||
++artists_received;
|
++artists_received;
|
||||||
|
|
||||||
@@ -574,7 +574,7 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const QString &artist_id
|
|||||||
}
|
}
|
||||||
|
|
||||||
int albums_received = 0;
|
int albums_received = 0;
|
||||||
for (const QJsonValue &value_item : array_items) {
|
for (const QJsonValue value_item : array_items) {
|
||||||
|
|
||||||
++albums_received;
|
++albums_received;
|
||||||
|
|
||||||
@@ -845,7 +845,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const QString &artist_id,
|
|||||||
bool multidisc = false;
|
bool multidisc = false;
|
||||||
SongList songs;
|
SongList songs;
|
||||||
int songs_received = 0;
|
int songs_received = 0;
|
||||||
for (const QJsonValue &value_item : json_items) {
|
for (const QJsonValue value_item : json_items) {
|
||||||
|
|
||||||
if (!value_item.isObject()) {
|
if (!value_item.isObject()) {
|
||||||
Error("Invalid Json reply, track is not a object.", value_item);
|
Error("Invalid Json reply, track is not a object.", value_item);
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonArray json_array_urls = json_urls.toArray();
|
QJsonArray json_array_urls = json_urls.toArray();
|
||||||
for (const QJsonValue &value : json_array_urls) {
|
for (const QJsonValue value : json_array_urls) {
|
||||||
urls << QUrl(value.toString());
|
urls << QUrl(value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user