From 021908320e6280ff15795c174ac13bf64cf1f443 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 2 Oct 2019 13:58:12 +0800 Subject: [PATCH] Preserve relative order when moving to top/bottom in queue Closes #11312. --- src/base/bittorrent/session.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index bcccf463f..bbd355ebf 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -1752,9 +1752,7 @@ void Session::decreaseTorrentsQueuePos(const QVector &hashes) void Session::topTorrentsQueuePos(const QVector &hashes) { using ElementType = std::pair; - std::priority_queue - , std::greater> torrentQueue; + std::priority_queue torrentQueue; // Sort torrents by queue position for (const InfoHash &infoHash : hashes) { @@ -1763,7 +1761,7 @@ void Session::topTorrentsQueuePos(const QVector &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 &hashes) using ElementType = std::pair; std::priority_queue - , std::less> torrentQueue; + , std::greater> torrentQueue; // Sort torrents by queue position for (const InfoHash &infoHash : hashes) { @@ -1787,7 +1785,7 @@ void Session::bottomTorrentsQueuePos(const QVector &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());