diff --git a/src/downloadedpiecesbar.h b/src/downloadedpiecesbar.h index 5f9c5c96a..3a04d9073 100644 --- a/src/downloadedpiecesbar.h +++ b/src/downloadedpiecesbar.h @@ -63,28 +63,31 @@ public: const qulonglong nb_pieces = pieces.size(); // Reduce the number of pieces before creating the pixmap // otherwise it can crash when there are too many pieces - if(nb_pieces > (uint)width()) { - const int ratio = floor(nb_pieces/(double)width()); - std::vector scaled_pieces; - std::vector scaled_downloading; + const uint w = width(); + if(nb_pieces > w) { + const uint ratio = floor(nb_pieces/(double)w); + bitfield scaled_pieces(ceil(nb_pieces/(double)ratio), false); + bitfield scaled_downloading(ceil(nb_pieces/(double)ratio), false); + uint scaled_index = 0; for(qulonglong i=0; i width()) { - const int ratio = floor(nb_pieces/(double)width()); + const uint w = width(); + if(nb_pieces > w) { + const qulonglong ratio = floor(nb_pieces/(double)w); std::vector scaled_avail; - for(int i=0; i