mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
BUGFIX: Fix possible crash when deleting a torrent
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.1.4
|
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.1.4
|
||||||
- BUGFIX: Make sure seeding torrents display a progress of 100%
|
- BUGFIX: Make sure seeding torrents display a progress of 100%
|
||||||
- BUGFIX: Usage display was improved and localized (--help)
|
- BUGFIX: Usage display was improved and localized (--help)
|
||||||
|
- BUGFIX: Fix possible crash when deleting a torrent
|
||||||
|
|
||||||
* Sun Jan 31 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.3
|
* Sun Jan 31 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.3
|
||||||
- BUGFIX: Fix "Append .!qB extension to complete files" (libtorrent v0.15)
|
- BUGFIX: Fix "Append .!qB extension to complete files" (libtorrent v0.15)
|
||||||
|
|||||||
@@ -213,7 +213,11 @@ void TransferListWidget::setRowColor(int row, QColor color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::deleteTorrent(int row, bool refresh_list) {
|
void TransferListWidget::deleteTorrent(int row, bool refresh_list) {
|
||||||
emit torrentAboutToBeRemoved(listModel->index(row, 0));
|
Q_ASSERT(row >= 0);
|
||||||
|
QModelIndex index = listModel->index(row, 0);
|
||||||
|
Q_ASSERT(index.isValid());
|
||||||
|
if(!index.isValid()) return;
|
||||||
|
emit torrentAboutToBeRemoved(index);
|
||||||
listModel->removeRow(row);
|
listModel->removeRow(row);
|
||||||
if(refresh_list)
|
if(refresh_list)
|
||||||
refreshList();
|
refreshList();
|
||||||
@@ -288,8 +292,7 @@ int TransferListWidget::updateTorrent(int row) {
|
|||||||
QString hash = getHashFromRow(row);
|
QString hash = getHashFromRow(row);
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(!h.is_valid()) {
|
if(!h.is_valid()) {
|
||||||
// Delete torrent
|
// Torrent will be deleted from list by caller
|
||||||
deleteTorrent(row, false);
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -404,10 +407,9 @@ int TransferListWidget::updateTorrent(int row) {
|
|||||||
listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)h.upload_payload_rate()));
|
listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)h.upload_payload_rate()));
|
||||||
// Share ratio
|
// Share ratio
|
||||||
listModel->setData(listModel->index(row, TR_RATIO), QVariant(BTSession->getRealRatio(hash)));
|
listModel->setData(listModel->index(row, TR_RATIO), QVariant(BTSession->getRealRatio(hash)));
|
||||||
}catch(invalid_handle e) {
|
}catch(invalid_handle) {
|
||||||
deleteTorrent(row, false);
|
// Torrent will be deleted by caller
|
||||||
s = STATE_INVALID;
|
s = STATE_INVALID;
|
||||||
qDebug("Caught Invalid handle exception, lucky us.");
|
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -497,7 +499,9 @@ void TransferListWidget::refreshList() {
|
|||||||
}
|
}
|
||||||
// Remove bad torrents from list
|
// Remove bad torrents from list
|
||||||
foreach(QString hash, bad_hashes) {
|
foreach(QString hash, bad_hashes) {
|
||||||
deleteTorrent(getRowFromHash(hash), false);
|
int row = getRowFromHash(hash);
|
||||||
|
if(row >= 0)
|
||||||
|
deleteTorrent(row, false);
|
||||||
}
|
}
|
||||||
// Update status filters counters
|
// Update status filters counters
|
||||||
emit torrentStatusUpdate(nb_downloading, nb_seeding, nb_active, nb_inactive);
|
emit torrentStatusUpdate(nb_downloading, nb_seeding, nb_active, nb_inactive);
|
||||||
@@ -936,6 +940,7 @@ void TransferListWidget::setSelectionLabel(QString label) {
|
|||||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
foreach(const QModelIndex &index, selectedIndexes) {
|
foreach(const QModelIndex &index, selectedIndexes) {
|
||||||
QString hash = getHashFromRow(mapToSource(index).row());
|
QString hash = getHashFromRow(mapToSource(index).row());
|
||||||
|
Q_ASSERT(!hash.isEmpty());
|
||||||
QString old_label = proxyModel->data(proxyModel->index(index.row(), TR_LABEL)).toString();
|
QString old_label = proxyModel->data(proxyModel->index(index.row(), TR_LABEL)).toString();
|
||||||
proxyModel->setData(proxyModel->index(index.row(), TR_LABEL), QVariant(label));
|
proxyModel->setData(proxyModel->index(index.row(), TR_LABEL), QVariant(label));
|
||||||
TorrentPersistentData::saveLabel(hash, label);
|
TorrentPersistentData::saveLabel(hash, label);
|
||||||
|
|||||||
Reference in New Issue
Block a user