mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-08 06:00:59 -07:00
Use Q_ASSERT() to check invariants
This commit is contained in:
parent
72d1d5d2dd
commit
b921d96f4b
1 changed files with 4 additions and 9 deletions
|
@ -271,8 +271,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
|
||||||
|
|
||||||
void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent)
|
void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
if (m_torrentMap.contains(torrent))
|
Q_ASSERT(!m_torrentMap.contains(torrent));
|
||||||
return;
|
|
||||||
|
|
||||||
const int row = m_torrentList.size();
|
const int row = m_torrentList.size();
|
||||||
|
|
||||||
|
@ -300,8 +299,7 @@ BitTorrent::TorrentHandle *TransferListModel::torrentHandle(const QModelIndex &i
|
||||||
void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent)
|
void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
const int row = m_torrentMap.value(torrent, -1);
|
const int row = m_torrentMap.value(torrent, -1);
|
||||||
if (row < 0)
|
Q_ASSERT(row >= 0);
|
||||||
return;
|
|
||||||
|
|
||||||
beginRemoveRows({}, row, row);
|
beginRemoveRows({}, row, row);
|
||||||
m_torrentList.removeAt(row);
|
m_torrentList.removeAt(row);
|
||||||
|
@ -316,8 +314,7 @@ void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle
|
||||||
void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const torrent)
|
void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
const int row = m_torrentMap.value(torrent, -1);
|
const int row = m_torrentMap.value(torrent, -1);
|
||||||
if (row < 0)
|
Q_ASSERT(row >= 0);
|
||||||
return;
|
|
||||||
|
|
||||||
emit dataChanged(index(row, 0), index(row, columnCount() - 1));
|
emit dataChanged(index(row, 0), index(row, columnCount() - 1));
|
||||||
}
|
}
|
||||||
|
@ -329,9 +326,7 @@ void TransferListModel::handleTorrentsUpdated(const QVector<BitTorrent::TorrentH
|
||||||
if (torrents.size() <= (m_torrentList.size() * 0.5)) {
|
if (torrents.size() <= (m_torrentList.size() * 0.5)) {
|
||||||
for (BitTorrent::TorrentHandle *const torrent : torrents) {
|
for (BitTorrent::TorrentHandle *const torrent : torrents) {
|
||||||
const int row = m_torrentMap.value(torrent, -1);
|
const int row = m_torrentMap.value(torrent, -1);
|
||||||
|
Q_ASSERT(row >= 0);
|
||||||
if (row < 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
emit dataChanged(index(row, 0), index(row, columns));
|
emit dataChanged(index(row, 0), index(row, columns));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue