mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 05:08:05 -06:00
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:
@@ -184,7 +184,7 @@ void SearchController::resultsAction()
|
||||
|
||||
const std::shared_ptr<SearchHandler> &searchHandler = iter.value();
|
||||
const QList<SearchResult> searchResults = searchHandler->results();
|
||||
const int size = searchResults.size();
|
||||
const qsizetype size = searchResults.size();
|
||||
|
||||
if (offset > size)
|
||||
throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
|
||||
|
||||
@@ -637,7 +637,7 @@ void TorrentsController::infoAction()
|
||||
});
|
||||
}
|
||||
|
||||
const int size = torrentList.size();
|
||||
const qsizetype size = torrentList.size();
|
||||
// normalize offset
|
||||
if (offset < 0)
|
||||
offset = size + offset;
|
||||
@@ -993,11 +993,11 @@ void TorrentsController::pieceStatesAction()
|
||||
|
||||
QJsonArray pieceStates;
|
||||
const QBitArray states = torrent->pieces();
|
||||
for (int i = 0; i < states.size(); ++i)
|
||||
for (qsizetype i = 0; i < states.size(); ++i)
|
||||
pieceStates.append(static_cast<int>(states[i]) * 2);
|
||||
|
||||
const QBitArray dlstates = torrent->fetchDownloadingPieces().takeResult();
|
||||
for (int i = 0; i < states.size(); ++i)
|
||||
for (qsizetype i = 0; i < states.size(); ++i)
|
||||
{
|
||||
if (dlstates[i])
|
||||
pieceStates[i] = 1;
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace
|
||||
|
||||
for (const auto &cookie : cookies)
|
||||
{
|
||||
const int idx = cookie.indexOf(u'=');
|
||||
const qsizetype idx = cookie.indexOf(u'=');
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
@@ -230,9 +230,9 @@ void WebApplication::translateDocument(QString &data) const
|
||||
{
|
||||
const QRegularExpression regex(u"QBT_TR\\((([^\\)]|\\)(?!QBT_TR))+)\\)QBT_TR\\[CONTEXT=([a-zA-Z_][a-zA-Z0-9_]*)\\]"_s);
|
||||
|
||||
int i = 0;
|
||||
qsizetype i = 0;
|
||||
bool found = true;
|
||||
while (i < data.size() && found)
|
||||
while ((i < data.size()) && found)
|
||||
{
|
||||
QRegularExpressionMatch regexMatch;
|
||||
i = data.indexOf(regex, i, ®exMatch);
|
||||
@@ -483,7 +483,7 @@ void WebApplication::configure()
|
||||
|
||||
for (const QStringView line : customHeaderLines)
|
||||
{
|
||||
const int idx = line.indexOf(u':');
|
||||
const qsizetype idx = line.indexOf(u':');
|
||||
if (idx < 0)
|
||||
{
|
||||
// require separator `:` to be present even if `value` field can be empty
|
||||
|
||||
Reference in New Issue
Block a user