mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-09 05:14:23 +00:00
Merge pull request #11521 from Chocobo1/errorStatus
Fix stuck in wrong torrent state
This commit is contained in:
commit
2e8b17e498
@ -4179,6 +4179,10 @@ void Session::createTorrentHandle(const lt::torrent_handle &nativeHandle)
|
|||||||
// Send new torrent signal
|
// Send new torrent signal
|
||||||
if (!params.restored)
|
if (!params.restored)
|
||||||
emit torrentNew(torrent);
|
emit torrentNew(torrent);
|
||||||
|
|
||||||
|
// Torrent could have error just after adding to libtorrent
|
||||||
|
if (torrent->hasError())
|
||||||
|
LogMsg(tr("Torrent errored. Torrent: \"%1\". Error: %2.").arg(torrent->name(), torrent->error()), Log::WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleAddTorrentAlert(const lt::add_torrent_alert *p)
|
void Session::handleAddTorrentAlert(const lt::add_torrent_alert *p)
|
||||||
|
@ -899,7 +899,10 @@ TorrentState TorrentHandle::state() const
|
|||||||
|
|
||||||
void TorrentHandle::updateState()
|
void TorrentHandle::updateState()
|
||||||
{
|
{
|
||||||
if (m_nativeStatus.state == lt::torrent_status::checking_resume_data) {
|
if (hasError()) {
|
||||||
|
m_state = TorrentState::Error;
|
||||||
|
}
|
||||||
|
else if (m_nativeStatus.state == lt::torrent_status::checking_resume_data) {
|
||||||
m_state = TorrentState::CheckingResumeData;
|
m_state = TorrentState::CheckingResumeData;
|
||||||
}
|
}
|
||||||
else if (isMoveInProgress()) {
|
else if (isMoveInProgress()) {
|
||||||
@ -908,8 +911,6 @@ void TorrentHandle::updateState()
|
|||||||
else if (isPaused()) {
|
else if (isPaused()) {
|
||||||
if (hasMissingFiles())
|
if (hasMissingFiles())
|
||||||
m_state = TorrentState::MissingFiles;
|
m_state = TorrentState::MissingFiles;
|
||||||
else if (hasError())
|
|
||||||
m_state = TorrentState::Error;
|
|
||||||
else
|
else
|
||||||
m_state = isSeed() ? TorrentState::PausedUploading : TorrentState::PausedDownloading;
|
m_state = isSeed() ? TorrentState::PausedUploading : TorrentState::PausedDownloading;
|
||||||
}
|
}
|
||||||
@ -961,12 +962,7 @@ bool TorrentHandle::hasMissingFiles() const
|
|||||||
|
|
||||||
bool TorrentHandle::hasError() const
|
bool TorrentHandle::hasError() const
|
||||||
{
|
{
|
||||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
return static_cast<bool>(m_nativeStatus.errc);
|
||||||
return (m_nativeStatus.paused && m_nativeStatus.errc);
|
|
||||||
#else
|
|
||||||
return ((m_nativeStatus.flags & lt::torrent_flags::paused)
|
|
||||||
&& m_nativeStatus.errc);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorrentHandle::hasFilteredPieces() const
|
bool TorrentHandle::hasFilteredPieces() const
|
||||||
|
@ -100,7 +100,10 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
break;
|
break;
|
||||||
case TransferListModel::TR_STATUS: {
|
case TransferListModel::TR_STATUS: {
|
||||||
const auto state = index.data().value<BitTorrent::TorrentState>();
|
const auto state = index.data().value<BitTorrent::TorrentState>();
|
||||||
|
const QString errorMsg = index.data(Qt::UserRole).toString();
|
||||||
QString display = getStatusString(state);
|
QString display = getStatusString(state);
|
||||||
|
if (state == BitTorrent::TorrentState::Error)
|
||||||
|
display += (": " + errorMsg);
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -184,7 +184,7 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const
|
|||||||
case TR_PROGRESS:
|
case TR_PROGRESS:
|
||||||
return torrent->progress();
|
return torrent->progress();
|
||||||
case TR_STATUS:
|
case TR_STATUS:
|
||||||
return QVariant::fromValue(torrent->state());
|
return (role == Qt::DisplayRole) ? QVariant::fromValue(torrent->state()) : torrent->error();
|
||||||
case TR_SEEDS:
|
case TR_SEEDS:
|
||||||
return (role == Qt::DisplayRole) ? torrent->seedsCount() : torrent->totalSeedsCount();
|
return (role == Qt::DisplayRole) ? torrent->seedsCount() : torrent->totalSeedsCount();
|
||||||
case TR_PEERS:
|
case TR_PEERS:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user