From 9a7e79bd0e3c8c7a8cc071dcb0ea1b26be275b67 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 15 Jun 2019 22:21:26 +0800 Subject: [PATCH 1/3] Improve handleFileErrorAlert error message --- src/base/bittorrent/session.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 368059544..ab39677c0 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4337,20 +4337,23 @@ void Session::handleMetadataReceivedAlert(libt::metadata_received_alert *p) void Session::handleFileErrorAlert(libt::file_error_alert *p) { - qDebug() << Q_FUNC_INFO; - // NOTE: Check this function! TorrentHandle *const torrent = m_torrents.value(p->handle.info_hash()); - if (torrent) { - const InfoHash hash = torrent->hash(); - if (!m_recentErroredTorrents.contains(hash)) { - m_recentErroredTorrents.insert(hash); - const QString msg = QString::fromStdString(p->message()); - LogMsg(tr("An I/O error occurred, '%1' paused. %2").arg(torrent->name(), msg)); - emit fullDiskError(torrent, msg); - } + if (!torrent) + return; - m_recentErroredTorrentsTimer->start(); + const InfoHash hash = torrent->hash(); + + if (!m_recentErroredTorrents.contains(hash)) { + m_recentErroredTorrents.insert(hash); + + const QString msg = QString::fromStdString(p->message()); + LogMsg(tr("File error alert. Torrent: \"%1\". File: \"%2\". Reason: %3") + .arg(torrent->name(), p->filename(), msg) + , Log::WARNING); + emit fullDiskError(torrent, msg); } + + m_recentErroredTorrentsTimer->start(); } void Session::handlePortmapWarningAlert(libt::portmap_error_alert *p) From ac9ba255d8ef9deb64bb1eb83d3cbf22b857dbb8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 11 Jun 2019 20:32:34 +0800 Subject: [PATCH 2/3] Set wheel event to accepted only if we handle it --- src/gui/properties/peerlistwidget.cpp | 4 ++-- src/gui/transferlistwidget.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index eab083c15..8f69ec633 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -462,10 +462,10 @@ void PeerListWidget::handleSortColumnChanged(int col) void PeerListWidget::wheelEvent(QWheelEvent *event) { - event->accept(); - if (event->modifiers() & Qt::ShiftModifier) { // Shift + scroll = horizontal scroll + event->accept(); + QWheelEvent scrollHEvent(event->pos(), event->globalPos(), event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal); QTreeView::wheelEvent(&scrollHEvent); return; diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 79606171f..eb629810c 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -1212,10 +1212,10 @@ bool TransferListWidget::loadSettings() void TransferListWidget::wheelEvent(QWheelEvent *event) { - event->accept(); - if (event->modifiers() & Qt::ShiftModifier) { // Shift + scroll = horizontal scroll + event->accept(); + QWheelEvent scrollHEvent(event->pos(), event->globalPos(), event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal); QTreeView::wheelEvent(&scrollHEvent); return; From d03209a73d6f68549a11838ea3342b393b8fa671 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 17 Jun 2019 11:56:27 +0800 Subject: [PATCH 3/3] Fix crash when removing phantom tags Normally a tag is stored in both session and torrent's fastresume. A phantom tag is a tag that is stored in fastresume but not in session. This crash can occur when user resets his config file and choose to remove tag from torrent. Closes #10569. --- src/gui/tagfiltermodel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/tagfiltermodel.cpp b/src/gui/tagfiltermodel.cpp index 02ab1c92f..99f22b67f 100644 --- a/src/gui/tagfiltermodel.cpp +++ b/src/gui/tagfiltermodel.cpp @@ -216,15 +216,15 @@ void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, c void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, const QString &tag) { - Q_ASSERT(torrent->tags().count() >= 0); - if (torrent->tags().count() == 0) + if (torrent->tags().empty()) untaggedItem()->increaseTorrentsCount(); const int row = findRow(tag); - Q_ASSERT(isValidRow(row)); - TagModelItem &item = m_tagItems[row]; + if (row < 0) + return; + + m_tagItems[row].decreaseTorrentsCount(); - item.decreaseTorrentsCount(); const QModelIndex i = index(row, 0, QModelIndex()); emit dataChanged(i, i); }