mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 22:18:05 -06:00
Don't change the processing order of alerts of different types
PR #23373. Closes #23319.
This commit is contained in:
committed by
Vladimir Golovnev (glassez)
parent
8f1fc451ae
commit
571094cc9c
@@ -5651,6 +5651,25 @@ void SessionImpl::fetchPendingAlerts(const lt::time_duration time)
|
|||||||
m_nativeSession->pop_alerts(&m_alerts);
|
m_nativeSession->pop_alerts(&m_alerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionImpl::endAlertSequence(const int alertType, const qsizetype alertCount)
|
||||||
|
{
|
||||||
|
qDebug() << "End alert sequence. Alert:" << lt::alert_name(alertType) << "Count:" << alertCount;
|
||||||
|
|
||||||
|
if (alertType == lt::add_torrent_alert::alert_type)
|
||||||
|
{
|
||||||
|
emit addTorrentAlertsReceived(alertCount);
|
||||||
|
|
||||||
|
if (!m_loadedTorrents.isEmpty())
|
||||||
|
{
|
||||||
|
if (isRestored())
|
||||||
|
m_torrentsQueueChanged = true;
|
||||||
|
|
||||||
|
emit torrentsLoaded(m_loadedTorrents);
|
||||||
|
m_loadedTorrents.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TorrentContentLayout SessionImpl::torrentContentLayout() const
|
TorrentContentLayout SessionImpl::torrentContentLayout() const
|
||||||
{
|
{
|
||||||
return m_torrentContentLayout;
|
return m_torrentContentLayout;
|
||||||
@@ -5667,28 +5686,26 @@ void SessionImpl::readAlerts()
|
|||||||
fetchPendingAlerts();
|
fetchPendingAlerts();
|
||||||
|
|
||||||
Q_ASSERT(m_loadedTorrents.isEmpty());
|
Q_ASSERT(m_loadedTorrents.isEmpty());
|
||||||
Q_ASSERT(m_receivedAddTorrentAlertsCount == 0);
|
|
||||||
|
|
||||||
if (!isRestored())
|
if (!isRestored())
|
||||||
m_loadedTorrents.reserve(MAX_PROCESSING_RESUMEDATA_COUNT);
|
m_loadedTorrents.reserve(MAX_PROCESSING_RESUMEDATA_COUNT);
|
||||||
|
|
||||||
|
int previousAlertType = -1;
|
||||||
|
qsizetype alertSequenceSize = 0;
|
||||||
for (const lt::alert *a : m_alerts)
|
for (const lt::alert *a : m_alerts)
|
||||||
handleAlert(a);
|
|
||||||
|
|
||||||
if (m_receivedAddTorrentAlertsCount > 0)
|
|
||||||
{
|
{
|
||||||
emit addTorrentAlertsReceived(m_receivedAddTorrentAlertsCount);
|
const int alertType = a->type();
|
||||||
m_receivedAddTorrentAlertsCount = 0;
|
if ((alertType != previousAlertType) && (previousAlertType != -1))
|
||||||
|
|
||||||
if (!m_loadedTorrents.isEmpty())
|
|
||||||
{
|
{
|
||||||
if (isRestored())
|
endAlertSequence(previousAlertType, alertSequenceSize);
|
||||||
m_torrentsQueueChanged = true;
|
alertSequenceSize = 0;
|
||||||
|
|
||||||
emit torrentsLoaded(m_loadedTorrents);
|
|
||||||
m_loadedTorrents.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleAlert(a);
|
||||||
|
++alertSequenceSize;
|
||||||
|
previousAlertType = alertType;
|
||||||
}
|
}
|
||||||
|
endAlertSequence(previousAlertType, alertSequenceSize);
|
||||||
|
|
||||||
// Some torrents may become "finished" after different alerts handling.
|
// Some torrents may become "finished" after different alerts handling.
|
||||||
processPendingFinishedTorrents();
|
processPendingFinishedTorrents();
|
||||||
@@ -5696,8 +5713,6 @@ void SessionImpl::readAlerts()
|
|||||||
|
|
||||||
void SessionImpl::handleAddTorrentAlert(const lt::add_torrent_alert *alert)
|
void SessionImpl::handleAddTorrentAlert(const lt::add_torrent_alert *alert)
|
||||||
{
|
{
|
||||||
++m_receivedAddTorrentAlertsCount;
|
|
||||||
|
|
||||||
if (alert->error)
|
if (alert->error)
|
||||||
{
|
{
|
||||||
const QString msg = QString::fromStdString(alert->message());
|
const QString msg = QString::fromStdString(alert->message());
|
||||||
|
|||||||
@@ -607,6 +607,7 @@ namespace BitTorrent
|
|||||||
void populateAdditionalTrackersFromURL();
|
void populateAdditionalTrackersFromURL();
|
||||||
|
|
||||||
void fetchPendingAlerts(lt::time_duration time = lt::time_duration::zero());
|
void fetchPendingAlerts(lt::time_duration time = lt::time_duration::zero());
|
||||||
|
void endAlertSequence(int alertType, qsizetype alertCount);
|
||||||
|
|
||||||
void moveTorrentStorage(const MoveStorageJob &job) const;
|
void moveTorrentStorage(const MoveStorageJob &job) const;
|
||||||
void handleMoveTorrentStorageJobFinished(const Path &newPath);
|
void handleMoveTorrentStorageJobFinished(const Path &newPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user