From 19f50a363d66e221978bb5363c7adac53a3b163c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 17 Jun 2019 11:56:27 +0800 Subject: [PATCH] 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 d2a98615a..d816a9699 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); }