mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 06:01:33 -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);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return m_torrentContentLayout;
|
||||
@@ -5667,28 +5686,26 @@ void SessionImpl::readAlerts()
|
||||
fetchPendingAlerts();
|
||||
|
||||
Q_ASSERT(m_loadedTorrents.isEmpty());
|
||||
Q_ASSERT(m_receivedAddTorrentAlertsCount == 0);
|
||||
|
||||
if (!isRestored())
|
||||
m_loadedTorrents.reserve(MAX_PROCESSING_RESUMEDATA_COUNT);
|
||||
|
||||
int previousAlertType = -1;
|
||||
qsizetype alertSequenceSize = 0;
|
||||
for (const lt::alert *a : m_alerts)
|
||||
handleAlert(a);
|
||||
|
||||
if (m_receivedAddTorrentAlertsCount > 0)
|
||||
{
|
||||
emit addTorrentAlertsReceived(m_receivedAddTorrentAlertsCount);
|
||||
m_receivedAddTorrentAlertsCount = 0;
|
||||
|
||||
if (!m_loadedTorrents.isEmpty())
|
||||
const int alertType = a->type();
|
||||
if ((alertType != previousAlertType) && (previousAlertType != -1))
|
||||
{
|
||||
if (isRestored())
|
||||
m_torrentsQueueChanged = true;
|
||||
|
||||
emit torrentsLoaded(m_loadedTorrents);
|
||||
m_loadedTorrents.clear();
|
||||
endAlertSequence(previousAlertType, alertSequenceSize);
|
||||
alertSequenceSize = 0;
|
||||
}
|
||||
|
||||
handleAlert(a);
|
||||
++alertSequenceSize;
|
||||
previousAlertType = alertType;
|
||||
}
|
||||
endAlertSequence(previousAlertType, alertSequenceSize);
|
||||
|
||||
// Some torrents may become "finished" after different alerts handling.
|
||||
processPendingFinishedTorrents();
|
||||
@@ -5696,8 +5713,6 @@ void SessionImpl::readAlerts()
|
||||
|
||||
void SessionImpl::handleAddTorrentAlert(const lt::add_torrent_alert *alert)
|
||||
{
|
||||
++m_receivedAddTorrentAlertsCount;
|
||||
|
||||
if (alert->error)
|
||||
{
|
||||
const QString msg = QString::fromStdString(alert->message());
|
||||
|
||||
@@ -607,6 +607,7 @@ namespace BitTorrent
|
||||
void populateAdditionalTrackersFromURL();
|
||||
|
||||
void fetchPendingAlerts(lt::time_duration time = lt::time_duration::zero());
|
||||
void endAlertSequence(int alertType, qsizetype alertCount);
|
||||
|
||||
void moveTorrentStorage(const MoveStorageJob &job) const;
|
||||
void handleMoveTorrentStorageJobFinished(const Path &newPath);
|
||||
|
||||
Reference in New Issue
Block a user