Browse Source

Preserve relative order when moving to top/bottom in queue

Closes #11312.
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
021908320e
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 10
      src/base/bittorrent/session.cpp

10
src/base/bittorrent/session.cpp

@ -1752,9 +1752,7 @@ void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1752,9 +1752,7 @@ void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes)
{
using ElementType = std::pair<int, TorrentHandle *>;
std::priority_queue<ElementType
, std::vector<ElementType>
, std::greater<ElementType>> torrentQueue;
std::priority_queue<ElementType> torrentQueue;
// Sort torrents by queue position
for (const InfoHash &infoHash : hashes) {
@ -1763,7 +1761,7 @@ void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1763,7 +1761,7 @@ void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes)
torrentQueue.emplace(torrent->queuePosition(), torrent);
}
// Top torrents queue position (starting with the one in the highest queue position)
// Top torrents queue position (starting with the one in the lowest queue position)
while (!torrentQueue.empty()) {
const TorrentHandle *torrent = torrentQueue.top().second;
torrentQueuePositionTop(torrent->nativeHandle());
@ -1778,7 +1776,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1778,7 +1776,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes)
using ElementType = std::pair<int, TorrentHandle *>;
std::priority_queue<ElementType
, std::vector<ElementType>
, std::less<ElementType>> torrentQueue;
, std::greater<ElementType>> torrentQueue;
// Sort torrents by queue position
for (const InfoHash &infoHash : hashes) {
@ -1787,7 +1785,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1787,7 +1785,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes)
torrentQueue.emplace(torrent->queuePosition(), torrent);
}
// Bottom torrents queue position (starting with the one in the lowest queue position)
// Bottom torrents queue position (starting with the one in the highest queue position)
while (!torrentQueue.empty()) {
const TorrentHandle *torrent = torrentQueue.top().second;
torrentQueuePositionBottom(torrent->nativeHandle());

Loading…
Cancel
Save