BUGFIX: Fix possible crash when changing torrents label

This commit is contained in:
Christophe Dumez
2010-02-07 18:39:37 +00:00
parent 6b99c84fe3
commit eeabf85e3b
2 changed files with 8 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
- BUGFIX: Make sure seeding torrents display a progress of 100%
- BUGFIX: Usage display was improved and localized (--help)
- BUGFIX: Fix possible crash when deleting a torrent
- BUGFIX: Fix possible crash when changing torrents label
* Sun Jan 31 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.3
- BUGFIX: Fix "Append .!qB extension to complete files" (libtorrent v0.15)

View File

@@ -938,11 +938,15 @@ void TransferListWidget::renameSelectedTorrent() {
void TransferListWidget::setSelectionLabel(QString label) {
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList hashes;
foreach(const QModelIndex &index, selectedIndexes) {
QString hash = getHashFromRow(mapToSource(index).row());
hashes << getHashFromRow(mapToSource(index).row());
}
foreach(const QString& hash, hashes) {
Q_ASSERT(!hash.isEmpty());
QString old_label = proxyModel->data(proxyModel->index(index.row(), TR_LABEL)).toString();
proxyModel->setData(proxyModel->index(index.row(), TR_LABEL), QVariant(label));
int row = getRowFromHash(hash);
QString old_label = listModel->data(listModel->index(row, TR_LABEL)).toString();
listModel->setData(listModel->index(row, TR_LABEL), QVariant(label));
TorrentPersistentData::saveLabel(hash, label);
emit torrentChangedLabel(old_label, label);
// Update save path if necessary