From 290d198977b3627e694d4e6f768c4c35a4702536 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 6 Mar 2020 01:47:28 +0800 Subject: [PATCH] Use proper type for piece index --- src/base/bittorrent/peerinfo.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base/bittorrent/peerinfo.cpp b/src/base/bittorrent/peerinfo.cpp index a95a99af8..e0a50fd3a 100644 --- a/src/base/bittorrent/peerinfo.cpp +++ b/src/base/bittorrent/peerinfo.cpp @@ -207,9 +207,15 @@ qlonglong PeerInfo::totalDownload() const QBitArray PeerInfo::pieces() const { +#if (LIBTORRENT_VERSION_NUM < 10200) + using PieceIndex = int; +#else + using PieceIndex = lt::piece_index_t; +#endif + QBitArray result(m_nativeInfo.pieces.size()); for (int i = 0; i < result.size(); ++i) { - if (m_nativeInfo.pieces[i]) + if (m_nativeInfo.pieces[PieceIndex {i}]) result.setBit(i, true); } return result;