Browse Source

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.
adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
19f50a363d
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 10
      src/gui/tagfiltermodel.cpp

10
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) void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, const QString &tag)
{ {
Q_ASSERT(torrent->tags().count() >= 0); if (torrent->tags().empty())
if (torrent->tags().count() == 0)
untaggedItem()->increaseTorrentsCount(); untaggedItem()->increaseTorrentsCount();
const int row = findRow(tag); const int row = findRow(tag);
Q_ASSERT(isValidRow(row)); if (row < 0)
TagModelItem &item = m_tagItems[row]; return;
m_tagItems[row].decreaseTorrentsCount();
item.decreaseTorrentsCount();
const QModelIndex i = index(row, 0, QModelIndex()); const QModelIndex i = index(row, 0, QModelIndex());
emit dataChanged(i, i); emit dataChanged(i, i);
} }

Loading…
Cancel
Save