Browse Source

Fix possible crash when changing torrents label

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
240c3508fe
  1. 10
      src/transferlistwidget.cpp

10
src/transferlistwidget.cpp

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

Loading…
Cancel
Save