Skip to content

Commit

Permalink
Update torrent states on queueing mode changed
Browse files Browse the repository at this point in the history
  • Loading branch information
glassez committed Apr 26, 2024
1 parent dad743e commit 781c88e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/base/bittorrent/sessionimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4412,6 +4412,9 @@ void SessionImpl::setQueueingSystemEnabled(const bool enabled)
m_torrentsQueueChanged = true;
else
removeTorrentsQueue();

for (TorrentImpl *torrent : asConst(m_torrents))
torrent->handleQueueingModeChanged();
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,9 @@ bool TorrentImpl::isStopped() const

bool TorrentImpl::isQueued() const
{
if (!m_session->isQueueingSystemEnabled())
return false;

// Torrent is Queued if it isn't in Stopped state but paused internally
return (!isStopped()
&& (m_nativeStatus.flags & lt::torrent_flags::auto_managed)
Expand Down Expand Up @@ -1153,7 +1156,7 @@ void TorrentImpl::updateState()
{
if (isStopped())
m_state = TorrentState::StoppedDownloading;
else if (m_session->isQueueingSystemEnabled() && isQueued())
else if (isQueued())
m_state = TorrentState::QueuedDownloading;
else
m_state = isForced() ? TorrentState::ForcedDownloadingMetadata : TorrentState::DownloadingMetadata;
Expand All @@ -1167,7 +1170,7 @@ void TorrentImpl::updateState()
{
if (isStopped())
m_state = TorrentState::StoppedUploading;
else if (m_session->isQueueingSystemEnabled() && isQueued())
else if (isQueued())
m_state = TorrentState::QueuedUploading;
else if (isForced())
m_state = TorrentState::ForcedUploading;
Expand All @@ -1180,7 +1183,7 @@ void TorrentImpl::updateState()
{
if (isStopped())
m_state = TorrentState::StoppedDownloading;
else if (m_session->isQueueingSystemEnabled() && isQueued())
else if (isQueued())
m_state = TorrentState::QueuedDownloading;
else if (isForced())
m_state = TorrentState::ForcedDownloading;
Expand Down Expand Up @@ -1953,6 +1956,11 @@ void TorrentImpl::handleStateUpdate(const lt::torrent_status &nativeStatus)
updateStatus(nativeStatus);
}

void TorrentImpl::handleQueueingModeChanged()
{
updateState();
}

void TorrentImpl::handleMoveStorageJobFinished(const Path &path, const MoveStorageContext context, const bool hasOutstandingJob)
{
if (context == MoveStorageContext::ChangeSavePath)
Expand Down
1 change: 1 addition & 0 deletions src/base/bittorrent/torrentimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ namespace BitTorrent

void handleAlert(const lt::alert *a);
void handleStateUpdate(const lt::torrent_status &nativeStatus);
void handleQueueingModeChanged();
void handleCategoryOptionsChanged();
void handleAppendExtensionToggled();
void handleUnwantedFolderToggled();
Expand Down
3 changes: 1 addition & 2 deletions src/gui/transferlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,7 @@ void TransferListWidget::displayListMenu()
needsStop = true;
}

const bool queued = (BitTorrent::Session::instance()->isQueueingSystemEnabled() && torrent->isQueued());

const bool queued = torrent->isQueued();
if (!isStopped && !rechecking && !queued)
oneCanForceReannounce = true;

Expand Down

0 comments on commit 781c88e

Please sign in to comment.