Fix a few narrowing conversions (#761)
* Fix narrowing conversion in album cover loader
* Fix narrowing conversions in discogs cover provider
* Fix narrowing conversions in spotify cover provider
* Add explicit conversion in moodbarbuilder
* Fix narrowing conversions in osd dbus
* Make WordyTimeNanosec use unsigned quint64
* Fix narrowing conversions in song
* Fix narrowing conversions in qobuz stream url request
* Make ConnectionInfo.msgLen use unsigned quint64
* Make AnalizerBase.timeout to signed int
* Fix narrowing conversions in album cover fetcher
* Make fht type be unsigned int
* Correct for type in blockanalizer and use std::fill where possible
* Revert "Fix narrowing conversions in song"
This reverts commit 3de291394d.
This commit is contained in:
@@ -482,9 +482,9 @@ void AlbumCoverChoiceController::ShowCover(const Song &song, const QPixmap &pixm
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverChoiceController::SearchCoverAutomatically(const Song &song) {
|
||||
quint64 AlbumCoverChoiceController::SearchCoverAutomatically(const Song &song) {
|
||||
|
||||
qint64 id = cover_fetcher_->FetchAlbumCover(song.effective_albumartist(), song.album(), song.title(), true);
|
||||
quint64 id = cover_fetcher_->FetchAlbumCover(song.effective_albumartist(), song.album(), song.title(), true);
|
||||
|
||||
cover_fetching_tasks_[id] = song;
|
||||
|
||||
@@ -640,12 +640,12 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &s : songs) urls << s.url();
|
||||
if (result.is_jpeg()) {
|
||||
qint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image_data);
|
||||
quint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image_data);
|
||||
QMutexLocker l(&mutex_cover_save_tasks_);
|
||||
cover_save_tasks_.insert(id, song);
|
||||
}
|
||||
else {
|
||||
qint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image);
|
||||
quint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image);
|
||||
QMutexLocker l(&mutex_cover_save_tasks_);
|
||||
cover_save_tasks_.insert(id, song);
|
||||
}
|
||||
@@ -684,7 +684,7 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &s : songs) urls << s.url();
|
||||
qint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, cover_filename);
|
||||
quint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, cover_filename);
|
||||
QMutexLocker l(&mutex_cover_save_tasks_);
|
||||
cover_save_tasks_.insert(id, song);
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
void ShowCover(const Song &song, const QPixmap &pixmap);
|
||||
|
||||
// Search for covers automatically
|
||||
qint64 SearchCoverAutomatically(const Song &song);
|
||||
quint64 SearchCoverAutomatically(const Song &song);
|
||||
|
||||
// Saves the chosen cover as manual cover path of this song in collection.
|
||||
void SaveArtAutomaticToSong(Song *song, const QUrl &art_automatic);
|
||||
@@ -185,7 +185,7 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
QAction *search_cover_auto_;
|
||||
|
||||
QMap<quint64, Song> cover_fetching_tasks_;
|
||||
QMap<qint64, Song> cover_save_tasks_;
|
||||
QMap<quint64, Song> cover_save_tasks_;
|
||||
QMutex mutex_cover_save_tasks_;
|
||||
|
||||
CollectionSettingsPage::SaveCoverType save_cover_type_;
|
||||
|
||||
@@ -75,7 +75,7 @@ AlbumCoverFetcherSearch::~AlbumCoverFetcherSearch() {
|
||||
void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||
|
||||
QList<int> ids = pending_requests_.keys();
|
||||
for (const quint64 id : ids) {
|
||||
for (const int id : ids) {
|
||||
pending_requests_.take(id)->CancelSearch(id);
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ float AlbumCoverFetcherSearch::ScoreImage(const QSize size) {
|
||||
const float size_score = std::sqrt(float(size.width() * size.height())) / kTargetSize;
|
||||
|
||||
// A 1:1 image scores 1.0, anything else scores less
|
||||
const float aspect_score = float(1.0) - float(std::max(size.width(), size.height()) - std::min(size.width(), size.height())) / std::max(size.height(), size.width());
|
||||
const float aspect_score = float(1.0) - float(std::max(size.width(), size.height()) - std::min(size.width(), size.height())) / float(std::max(size.height(), size.width()));
|
||||
|
||||
return size_score + aspect_score;
|
||||
|
||||
|
||||
@@ -545,55 +545,55 @@ void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply, const QUrl &cov
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QString &cover_filename) {
|
||||
quint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QString &cover_filename) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
quint64 id = ++save_image_async_id_;
|
||||
QMetaObject::invokeMethod(this, "SaveEmbeddedCover", Qt::QueuedConnection, Q_ARG(qint64, id), Q_ARG(QString, song_filename), Q_ARG(QString, cover_filename));
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QImage &image) {
|
||||
quint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QImage &image) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
quint64 id = ++save_image_async_id_;
|
||||
QMetaObject::invokeMethod(this, "SaveEmbeddedCover", Qt::QueuedConnection, Q_ARG(qint64, id), Q_ARG(QString, song_filename), Q_ARG(QImage, image));
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QByteArray &image_data) {
|
||||
quint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QByteArray &image_data) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
quint64 id = ++save_image_async_id_;
|
||||
QMetaObject::invokeMethod(this, "SaveEmbeddedCover", Qt::QueuedConnection, Q_ARG(qint64, id), Q_ARG(QString, song_filename), Q_ARG(QByteArray, image_data));
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QString &cover_filename) {
|
||||
quint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QString &cover_filename) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
quint64 id = ++save_image_async_id_;
|
||||
QMetaObject::invokeMethod(this, "SaveEmbeddedCover", Qt::QueuedConnection, Q_ARG(qint64, id), Q_ARG(QList<QUrl>, urls), Q_ARG(QString, cover_filename));
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QImage &image) {
|
||||
quint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QImage &image) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
quint64 id = ++save_image_async_id_;
|
||||
QMetaObject::invokeMethod(this, "SaveEmbeddedCover", Qt::QueuedConnection, Q_ARG(qint64, id), Q_ARG(QList<QUrl>, urls), Q_ARG(QImage, image));
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QByteArray &image_data) {
|
||||
quint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QByteArray &image_data) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
quint64 id = ++save_image_async_id_;
|
||||
QMetaObject::invokeMethod(this, "SaveEmbeddedCover", Qt::QueuedConnection, Q_ARG(qint64, id), Q_ARG(QList<QUrl>, urls), Q_ARG(QByteArray, image_data));
|
||||
return id;
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ class AlbumCoverLoader : public QObject {
|
||||
void CancelTask(const quint64 id);
|
||||
void CancelTasks(const QSet<quint64> &ids);
|
||||
|
||||
qint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QString &cover_filename);
|
||||
qint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QImage &image);
|
||||
qint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QByteArray &image_data);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QString &cover_filename);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QImage &image);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QByteArray &image_data);
|
||||
quint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QString &cover_filename);
|
||||
quint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QImage &image);
|
||||
quint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QByteArray &image_data);
|
||||
quint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QString &cover_filename);
|
||||
quint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QImage &image);
|
||||
quint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QByteArray &image_data);
|
||||
|
||||
signals:
|
||||
void ExitFinished();
|
||||
|
||||
@@ -214,7 +214,7 @@ class AlbumCoverManager : public QMainWindow {
|
||||
QPushButton *abort_progress_;
|
||||
int jobs_;
|
||||
|
||||
QMultiMap<qint64, AlbumItem*> cover_save_tasks_;
|
||||
QMultiMap<quint64, AlbumItem*> cover_save_tasks_;
|
||||
QList<AlbumItem*> cover_save_tasks2_;
|
||||
|
||||
QListWidgetItem *all_artists_;
|
||||
|
||||
@@ -229,7 +229,7 @@ QByteArray DiscogsCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const quint64 id) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
@@ -285,7 +285,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
Error("Invalid Json reply, results value object is missing ID, title or resource_url.", obj_result);
|
||||
continue;
|
||||
}
|
||||
quint64 release_id = obj_result["id"].toDouble();
|
||||
quint64 release_id = obj_result["id"].toInt();
|
||||
QUrl resource_url(obj_result["resource_url"].toString());
|
||||
QString title = obj_result["title"].toString();
|
||||
|
||||
@@ -336,7 +336,7 @@ void DiscogsCoverProvider::SendReleaseRequest(const DiscogsCoverReleaseContext &
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int search_id, const quint64 release_id) {
|
||||
void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const quint64 search_id, const quint64 release_id) {
|
||||
|
||||
if (!replies_.contains(reply)) return;
|
||||
replies_.removeAll(reply);
|
||||
@@ -440,7 +440,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
int width = obj_image["width"].toInt();
|
||||
int height = obj_image["height"].toInt();
|
||||
if (width < 300 || height < 300) continue;
|
||||
const float aspect_score = float(1.0) - float(std::max(width, height) - std::min(width, height)) / std::max(height, width);
|
||||
const float aspect_score = float(1.0) - float(std::max(width, height) - std::min(width, height)) / float(std::max(height, width));
|
||||
if (aspect_score < 0.85) continue;
|
||||
CoverProviderSearchResult result;
|
||||
result.artist = artist;
|
||||
|
||||
@@ -90,8 +90,8 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
|
||||
private slots:
|
||||
void FlushRequests();
|
||||
void HandleSearchReply(QNetworkReply *reply, const int id);
|
||||
void HandleReleaseReply(QNetworkReply *reply, const int id, const quint64 release_id);
|
||||
void HandleSearchReply(QNetworkReply *reply, const quint64 id);
|
||||
void HandleReleaseReply(QNetworkReply *reply, const quint64 id, const quint64 release_id);
|
||||
|
||||
private:
|
||||
static const char *kUrlSearch;
|
||||
|
||||
@@ -80,7 +80,7 @@ SpotifyCoverProvider::SpotifyCoverProvider(Application *app, NetworkAccessManage
|
||||
s.endGroup();
|
||||
|
||||
if (!refresh_token_.isEmpty()) {
|
||||
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
|
||||
quint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
|
||||
if (time < 1) time = 1;
|
||||
refresh_login_timer_.setInterval(static_cast<int>(time * kMsecPerSec));
|
||||
refresh_login_timer_.start();
|
||||
|
||||
Reference in New Issue
Block a user