Use proper return type

`count()`, `length()`, `size()`, `indexOf()` and `lastIndexOf()` were
returning `int` in Qt5. In Qt6 they return `qsizetype`.

PR #23317.
This commit is contained in:
Chocobo1
2025-09-29 03:08:02 +08:00
committed by GitHub
parent 01ac8c012c
commit eed0e56d1a
39 changed files with 86 additions and 85 deletions

View File

@@ -1403,7 +1403,7 @@ QList<qreal> TorrentImpl::filesProgress() const
if (!hasMetadata())
return {};
const int count = m_filesProgress.size();
const qsizetype count = m_filesProgress.size();
Q_ASSERT(count == filesCount());
if (count != filesCount()) [[unlikely]]
return {};
@@ -1710,7 +1710,7 @@ void TorrentImpl::applyFirstLastPiecePriority(const bool enabled)
// Updating file priorities is an async operation in libtorrent, when we just updated it and immediately query it
// we might get the old/wrong values, so we rely on `updatedFilePrio` in this case.
for (int fileIndex = 0; fileIndex < m_filePriorities.size(); ++fileIndex)
for (qsizetype fileIndex = 0; fileIndex < m_filePriorities.size(); ++fileIndex)
{
const DownloadPriority filePrio = m_filePriorities[fileIndex];
if (filePrio <= DownloadPriority::Ignored)
@@ -1808,7 +1808,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
m_filesProgress.resize(filesCount());
updateProgress();
for (int i = 0; i < fileNames.size(); ++i)
for (qsizetype i = 0; i < fileNames.size(); ++i)
{
const auto nativeIndex = nativeIndexes.at(i);
@@ -1822,7 +1822,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
}
m_session->applyFilenameFilter(m_filePaths, m_filePriorities);
for (int i = 0; i < m_filePriorities.size(); ++i)
for (qsizetype i = 0; i < m_filePriorities.size(); ++i)
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(m_filePriorities[i]);
p.save_path = savePath.toString().toStdString();
@@ -2152,7 +2152,7 @@ void TorrentImpl::handleSaveResumeData(lt::add_torrent_params params)
const auto nativeIndexes = metadata.nativeIndexes();
m_indexMap.reserve(filePaths.size());
for (int i = 0; i < filePaths.size(); ++i)
for (qsizetype i = 0; i < filePaths.size(); ++i)
{
const auto nativeIndex = nativeIndexes.at(i);
m_indexMap[nativeIndex] = i;
@@ -2931,7 +2931,7 @@ void TorrentImpl::prioritizeFiles(const QList<DownloadPriority> &priorities)
// Reset 'm_hasSeedStatus' if needed in order to react again to
// "torrent finished" event and e.g. show tray notifications
const QList<DownloadPriority> oldPriorities = filePriorities();
for (int i = 0; i < oldPriorities.size(); ++i)
for (qsizetype i = 0; i < oldPriorities.size(); ++i)
{
if ((oldPriorities[i] == DownloadPriority::Ignored)
&& (priorities[i] > DownloadPriority::Ignored)
@@ -2945,7 +2945,7 @@ void TorrentImpl::prioritizeFiles(const QList<DownloadPriority> &priorities)
const int internalFilesCount = m_torrentInfo.nativeInfo()->files().num_files(); // including .pad files
auto nativePriorities = std::vector<lt::download_priority_t>(internalFilesCount, LT::toNative(DownloadPriority::Normal));
const auto nativeIndexes = m_torrentInfo.nativeIndexes();
for (int i = 0; i < priorities.size(); ++i)
for (qsizetype i = 0; i < priorities.size(); ++i)
nativePriorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(priorities[i]);
qDebug() << Q_FUNC_INFO << "Changing files priorities...";