Fix cast warnings with MSVC

This commit is contained in:
Jonas Kvinge
2025-03-25 00:37:07 +01:00
parent d5281abb22
commit 5e031be42c
59 changed files with 207 additions and 207 deletions

View File

@@ -598,7 +598,7 @@ void Database::BackupFile(const QString &filename) {
do {
ret = sqlite3_backup_step(backup, 16);
const int page_count = sqlite3_backup_pagecount(backup);
task_manager_->SetTaskProgress(task_id, page_count - sqlite3_backup_remaining(backup), page_count);
task_manager_->SetTaskProgress(task_id, static_cast<quint64>(page_count - sqlite3_backup_remaining(backup)), static_cast<quint64>(page_count));
}
while (ret == SQLITE_OK);

View File

@@ -92,7 +92,7 @@ void DeleteFiles::ProcessSomeFiles() {
// None left?
if (progress_ >= songs_.count()) {
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count());
task_manager_->SetTaskProgress(task_id_, static_cast<quint64>(progress_), static_cast<quint64>(songs_.count()));
QString error_text;
storage_->FinishCopy(songs_with_errors_.isEmpty(), error_text);
@@ -114,7 +114,7 @@ void DeleteFiles::ProcessSomeFiles() {
const qint64 n = qMin(static_cast<qint64>(songs_.count()), static_cast<qint64>(progress_ + kBatchSize));
for (; progress_ < n; ++progress_) {
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count());
task_manager_->SetTaskProgress(task_id_, static_cast<quint64>(progress_), static_cast<quint64>(songs_.count()));
const Song song = songs_.value(progress_);

View File

@@ -52,7 +52,7 @@ LocalRedirectServer::~LocalRedirectServer() {
bool LocalRedirectServer::Listen() {
if (!listen(QHostAddress::LocalHost, port_)) {
if (!listen(QHostAddress::LocalHost, static_cast<quint64>(port_))) {
success_ = false;
error_ = errorString();
return false;

View File

@@ -2566,10 +2566,10 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
}
if (options.seek_to() != -1) {
app_->player()->SeekTo(options.seek_to());
app_->player()->SeekTo(static_cast<quint64>(options.seek_to()));
}
else if (options.seek_by() != 0) {
app_->player()->SeekTo(app_->player()->engine()->position_nanosec() / kNsecPerSec + options.seek_by());
app_->player()->SeekTo(static_cast<quint64>(app_->player()->engine()->position_nanosec() / kNsecPerSec + options.seek_by()));
}
if (options.play_track_at() != -1) app_->player()->PlayAt(options.play_track_at(), false, 0, EngineBase::TrackChangeType::Manual, Playlist::AutoScroll::Maybe, true);

View File

@@ -88,6 +88,4 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c
}
}
return 0;
}

View File

@@ -86,7 +86,7 @@ void NetworkProxyFactory::ReloadSettings() {
mode_ = static_cast<Mode>(s.value("mode", static_cast<int>(Mode::System)).toInt());
type_ = QNetworkProxy::ProxyType(s.value("type", QNetworkProxy::HttpProxy).toInt());
hostname_ = s.value("hostname").toString();
port_ = s.value("port", 8080).toInt();
port_ = s.value("port", 8080).toULongLong();
use_authentication_ = s.value("use_authentication", false).toBool();
username_ = s.value("username").toString();
password_ = s.value("password").toString();

View File

@@ -57,7 +57,7 @@ class NetworkProxyFactory : public QNetworkProxyFactory {
Mode mode_;
QNetworkProxy::ProxyType type_;
QString hostname_;
int port_;
quint64 port_;
bool use_authentication_;
QString username_;
QString password_;

View File

@@ -182,7 +182,7 @@ void OAuthenticator::LoadSession() {
expires_in_ = s.value(kExpiresIn, 0LL).toLongLong();
login_time_ = s.value(kLoginTime, 0LL).toLongLong();
country_code_ = s.value(kCountryCode).toString();
user_id_ = s.value(kUserId).toInt();
user_id_ = s.value(kUserId).toULongLong();
s.endGroup();
StartRefreshLoginTimer();
@@ -557,7 +557,7 @@ void OAuthenticator::AccessTokenRequestFinished(QNetworkReply *reply) {
const QJsonObject object_user = json_object["user"_L1].toObject();
if (object_user.contains("countryCode"_L1) && object_user.contains("userId"_L1)) {
country_code_ = object_user["countryCode"_L1].toString();
user_id_ = object_user["userId"_L1].toInt();
user_id_ = static_cast<quint64>(object_user["userId"_L1].toInt());
}
}

View File

@@ -173,7 +173,7 @@ void Player::LoadVolume() {
Settings s;
s.beginGroup(kSettingsGroup);
const uint volume = s.value(kVolume, 100).toInt();
const uint volume = s.value(kVolume, 100).toUInt();
s.endGroup();
SetVolume(volume);
@@ -240,7 +240,7 @@ void Player::ResumePlayback() {
s.beginGroup(kSettingsGroup);
const EngineBase::State playback_state = static_cast<EngineBase::State>(s.value(kPlaybackState, static_cast<int>(EngineBase::State::Empty)).toInt());
const int playback_playlist = s.value(kPlaybackPlaylist, -1).toInt();
const int playback_position = s.value(kPlaybackPosition, 0).toInt();
const quint64 playback_position = s.value(kPlaybackPosition, 0).toULongLong();
s.endGroup();
if (playback_playlist == playlist_manager_->current()->id()) {
@@ -372,7 +372,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
if (is_current) {
qLog(Debug) << "Playing song" << current_item->Metadata().title() << result.stream_url_ << "position" << play_offset_nanosec_;
engine_->Play(result.media_url_, result.stream_url_, pause_, stream_change_type_, song.has_cue(), song.beginning_nanosec(), song.end_nanosec(), play_offset_nanosec_, song.ebur128_integrated_loudness_lufs());
engine_->Play(result.media_url_, result.stream_url_, pause_, stream_change_type_, song.has_cue(), static_cast<quint64>(song.beginning_nanosec()), song.end_nanosec(), play_offset_nanosec_, song.ebur128_integrated_loudness_lufs());
current_item_ = current_item;
play_offset_nanosec_ = 0;
}
@@ -528,7 +528,7 @@ void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll
}
else {
pause_time_ = QDateTime::currentDateTime();
play_offset_nanosec_ = engine_->position_nanosec();
play_offset_nanosec_ = static_cast<quint64>(engine_->position_nanosec());
engine_->Pause();
}
break;
@@ -556,10 +556,10 @@ void Player::UnPause() {
if (current_item_ && pause_time_.isValid()) {
const Song &song = current_item_->Metadata();
if (url_handlers_->CanHandle(song.url()) && song.stream_url_can_expire()) {
const quint64 time = QDateTime::currentSecsSinceEpoch() - pause_time_.toSecsSinceEpoch();
const qint64 time = QDateTime::currentSecsSinceEpoch() - pause_time_.toSecsSinceEpoch();
if (time >= 30) { // Stream URL might be expired.
qLog(Debug) << "Re-requesting stream URL for" << song.url();
play_offset_nanosec_ = engine_->position_nanosec();
play_offset_nanosec_ = static_cast<quint64>(engine_->position_nanosec());
UrlHandler *url_handler = url_handlers_->GetUrlHandler(song.url());
HandleLoadResult(url_handler->StartLoading(song.url()));
return;
@@ -654,7 +654,7 @@ void Player::EngineStateChanged(const EngineBase::State state) {
switch (state) {
case EngineBase::State::Paused:
pause_time_ = QDateTime::currentDateTime();
play_offset_nanosec_ = engine_->position_nanosec();
play_offset_nanosec_ = static_cast<quint64>(engine_->position_nanosec());
Q_EMIT Paused();
break;
case EngineBase::State::Playing:
@@ -774,7 +774,7 @@ void Player::PlayAt(const int index, const bool pause, const quint64 offset_nano
}
else {
qLog(Debug) << "Playing song" << current_item_->Metadata().title() << url << "position" << offset_nanosec;
engine_->Play(current_item_->Url(), url, pause, change, current_item_->Metadata().has_cue(), current_item_->effective_beginning_nanosec(), current_item_->effective_end_nanosec(), offset_nanosec, current_item_->effective_ebur128_integrated_loudness_lufs());
engine_->Play(current_item_->Url(), url, pause, change, current_item_->Metadata().has_cue(), static_cast<quint64>(current_item_->effective_beginning_nanosec()), current_item_->effective_end_nanosec(), offset_nanosec, current_item_->effective_ebur128_integrated_loudness_lufs());
}
}
@@ -782,7 +782,7 @@ void Player::PlayAt(const int index, const bool pause, const quint64 offset_nano
void Player::CurrentMetadataChanged(const Song &metadata) {
// Those things might have changed (especially when a previously invalid song was reloaded) so we push the latest version into Engine
engine_->RefreshMarkers(metadata.beginning_nanosec(), metadata.end_nanosec());
engine_->RefreshMarkers(static_cast<quint64>(metadata.beginning_nanosec()), metadata.end_nanosec());
}
@@ -796,7 +796,7 @@ void Player::SeekTo(const quint64 seconds) {
}
const qint64 nanosec = qBound(0LL, static_cast<qint64>(seconds) * kNsecPerSec, length_nanosec);
engine_->Seek(nanosec);
engine_->Seek(static_cast<quint64>(nanosec));
qLog(Debug) << "Track seeked to" << nanosec << "ns - updating scrobble point";
playlist_manager_->active()->UpdateScrobblePoint(nanosec);
@@ -810,11 +810,11 @@ void Player::SeekTo(const quint64 seconds) {
}
void Player::SeekForward() {
SeekTo(engine()->position_nanosec() / kNsecPerSec + seek_step_sec_);
SeekTo(static_cast<quint64>(engine()->position_nanosec() / kNsecPerSec + seek_step_sec_));
}
void Player::SeekBackward() {
SeekTo(engine()->position_nanosec() / kNsecPerSec - seek_step_sec_);
SeekTo(static_cast<quint64>(engine()->position_nanosec() / kNsecPerSec - seek_step_sec_));
}
void Player::EngineMetadataReceived(const EngineMetadata &engine_metadata) {

View File

@@ -140,12 +140,12 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) {
for (int i = 0; i < actions_.count(); ++i) {
const QAction *action = actions_[i];
THUMBBUTTON *button = &buttons[i];
button->iId = i;
button->iId = static_cast<UINT>(i);
SetupButton(action, button);
}
qLog(Debug) << "Adding" << actions_.count() << "buttons";
HRESULT hr = taskbar_list_->ThumbBarAddButtons(reinterpret_cast<HWND>(widget_->winId()), actions_.count(), buttons);
HRESULT hr = taskbar_list_->ThumbBarAddButtons(reinterpret_cast<HWND>(widget_->winId()), static_cast<UINT>(actions_.count()), buttons);
if (hr != S_OK) {
qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD(hr);
}
@@ -185,11 +185,11 @@ void Windows7ThumbBar::ActionChanged() {
QAction *action = actions_[i];
THUMBBUTTON *button = &buttons[i];
button->iId = i;
button->iId = static_cast<UINT>(i);
SetupButton(action, button);
}
HRESULT hr = taskbar_list_->ThumbBarUpdateButtons(reinterpret_cast<HWND>(widget_->winId()), actions_.count(), buttons);
HRESULT hr = taskbar_list_->ThumbBarUpdateButtons(reinterpret_cast<HWND>(widget_->winId()), static_cast<UINT>(actions_.count()), buttons);
if (hr != S_OK) {
qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD(hr);
}