diff --git a/src/base/bittorrent/magneturi.cpp b/src/base/bittorrent/magneturi.cpp index cf755e1a7..ef8f7b812 100644 --- a/src/base/bittorrent/magneturi.cpp +++ b/src/base/bittorrent/magneturi.cpp @@ -83,13 +83,13 @@ MagnetUri::MagnetUri(const QString &source) m_name = QString::fromStdString(m_addTorrentParams.name); - m_trackers.reserve(m_addTorrentParams.trackers.size()); + m_trackers.reserve(static_cast(m_addTorrentParams.trackers.size())); for (const std::string &tracker : m_addTorrentParams.trackers) m_trackers.append({QString::fromStdString(tracker)}); - m_urlSeeds.reserve(m_addTorrentParams.url_seeds.size()); + m_urlSeeds.reserve(static_cast(m_addTorrentParams.url_seeds.size())); for (const std::string &urlSeed : m_addTorrentParams.url_seeds) - m_urlSeeds.append(QUrl(QString::fromStdString(urlSeed))); + m_urlSeeds.append(QString::fromStdString(urlSeed)); } bool MagnetUri::isValid() const diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 875afba45..3ca276791 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4830,7 +4830,7 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert void Session::handleStateUpdateAlert(const lt::state_update_alert *p) { QVector updatedTorrents; - updatedTorrents.reserve(p->status.size()); + updatedTorrents.reserve(static_cast(p->status.size())); for (const lt::torrent_status &status : p->status) { diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 04a41dced..0818cc0d7 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -112,8 +112,8 @@ namespace QString firstTrackerMessage; QString firstErrorMessage; #if (LIBTORRENT_VERSION_NUM >= 20000) - const int numEndpoints = nativeEntry.endpoints.size() * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1); - trackerEntry.endpoints.reserve(numEndpoints); + const size_t numEndpoints = nativeEntry.endpoints.size() * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1); + trackerEntry.endpoints.reserve(static_cast(numEndpoints)); for (const lt::announce_endpoint &endpoint : nativeEntry.endpoints) { for (const auto protocolVersion : {lt::protocol_version::V1, lt::protocol_version::V2}) @@ -473,7 +473,7 @@ QVector TorrentImpl::trackers() const const std::vector nativeTrackers = m_nativeHandle.trackers(); QVector entries; - entries.reserve(nativeTrackers.size()); + entries.reserve(static_cast(nativeTrackers.size())); for (const lt::announce_entry &tracker : nativeTrackers) { @@ -560,10 +560,10 @@ QVector TorrentImpl::urlSeeds() const const std::set currentSeeds = m_nativeHandle.url_seeds(); QVector urlSeeds; - urlSeeds.reserve(currentSeeds.size()); + urlSeeds.reserve(static_cast(currentSeeds.size())); for (const std::string &urlSeed : currentSeeds) - urlSeeds.append(QUrl(urlSeed.c_str())); + urlSeeds.append(QString::fromStdString(urlSeed)); return urlSeeds; } @@ -1223,9 +1223,11 @@ QVector TorrentImpl::peers() const m_nativeHandle.get_peer_info(nativePeers); QVector peers; - peers.reserve(nativePeers.size()); + peers.reserve(static_cast(nativePeers.size())); + for (const lt::peer_info &peer : nativePeers) peers << PeerInfo(this, peer); + return peers; } diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index e610b8219..aaccedac9 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -306,10 +306,11 @@ QVector TorrentInfo::trackers() const const std::vector trackers = m_nativeInfo->trackers(); QVector ret; - ret.reserve(trackers.size()); + ret.reserve(static_cast(trackers.size())); for (const lt::announce_entry &tracker : trackers) ret.append({QString::fromStdString(tracker.url)}); + return ret; } @@ -320,7 +321,7 @@ QVector TorrentInfo::urlSeeds() const const std::vector &nativeWebSeeds = m_nativeInfo->web_seeds(); QVector urlSeeds; - urlSeeds.reserve(nativeWebSeeds.size()); + urlSeeds.reserve(static_cast(nativeWebSeeds.size())); for (const lt::web_seed_entry &webSeed : nativeWebSeeds) { @@ -360,11 +361,10 @@ QVector TorrentInfo::fileIndicesForPiece(const int pieceIndex) const if (!isValid() || (pieceIndex < 0) || (pieceIndex >= piecesCount())) return {}; - const std::vector files( - nativeInfo()->map_block(lt::piece_index_t {pieceIndex}, 0 - , nativeInfo()->piece_size(lt::piece_index_t {pieceIndex}))); + const std::vector files = nativeInfo()->map_block( + lt::piece_index_t {pieceIndex}, 0, nativeInfo()->piece_size(lt::piece_index_t {pieceIndex})); QVector res; - res.reserve(int(files.size())); + res.reserve(static_cast(files.size())); std::transform(files.begin(), files.end(), std::back_inserter(res), [](const lt::file_slice &s) { return static_cast(s.file_index); }); diff --git a/src/base/logger.cpp b/src/base/logger.cpp index fc5c358e6..88835cc99 100644 --- a/src/base/logger.cpp +++ b/src/base/logger.cpp @@ -39,7 +39,7 @@ namespace QVector loadFromBuffer(const boost::circular_buffer_space_optimized &src, const int offset = 0) { QVector ret; - ret.reserve(src.size() - offset); + ret.reserve(static_cast(src.size()) - offset); std::copy((src.begin() + offset), src.end(), std::back_inserter(ret)); return ret; } @@ -95,7 +95,7 @@ QVector Logger::getMessages(const int lastKnownId) const const QReadLocker locker(&m_lock); const int diff = m_msgCounter - lastKnownId - 1; - const int size = m_messages.size(); + const int size = static_cast(m_messages.size()); if ((lastKnownId == -1) || (diff >= size)) return loadFromBuffer(m_messages); @@ -111,7 +111,7 @@ QVector Logger::getPeers(const int lastKnownId) const const QReadLocker locker(&m_lock); const int diff = m_peerCounter - lastKnownId - 1; - const int size = m_peers.size(); + const int size = static_cast(m_peers.size()); if ((lastKnownId == -1) || (diff >= size)) return loadFromBuffer(m_peers); diff --git a/src/gui/log/logmodel.cpp b/src/gui/log/logmodel.cpp index 50386e323..8c8d4b023 100644 --- a/src/gui/log/logmodel.cpp +++ b/src/gui/log/logmodel.cpp @@ -79,7 +79,7 @@ BaseLogModel::BaseLogModel(QObject *parent) int BaseLogModel::rowCount(const QModelIndex &) const { - return m_messages.size(); + return static_cast(m_messages.size()); } int BaseLogModel::columnCount(const QModelIndex &) const @@ -120,7 +120,7 @@ void BaseLogModel::addNewMessage(const BaseLogModel::Message &message) // but because of calling of beginInsertRows function we'll have ghost rows. if (m_messages.size() == MAX_VISIBLE_MESSAGES) { - const int lastMessage = m_messages.size() - 1; + const int lastMessage = static_cast(m_messages.size()) - 1; beginRemoveRows(QModelIndex(), lastMessage, lastMessage); m_messages.pop_back(); endRemoveRows(); diff --git a/src/gui/tagfiltermodel.cpp b/src/gui/tagfiltermodel.cpp index 9b18c0781..a0a13e667 100644 --- a/src/gui/tagfiltermodel.cpp +++ b/src/gui/tagfiltermodel.cpp @@ -317,7 +317,7 @@ TagModelItem *TagFilterModel::findItem(const QString &tag) QVector TagFilterModel::findItems(const TagSet &tags) { QVector items; - items.reserve(tags.size()); + items.reserve(tags.count()); for (const QString &tag : tags) { TagModelItem *item = findItem(tag);