mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-07 08:58:38 +00:00
Fix crashing in AddTorrentDialog when removing torrents from the list
Do not allow duplicate torrents in the AddTorrentDialog
This commit is contained in:
parent
32be4ed4ad
commit
a69efdfc56
1 changed files with 19 additions and 7 deletions
|
@ -181,6 +181,10 @@ class AddTorrentDialog(component.Component):
|
||||||
log.debug("Unable to open torrent file: %s", e)
|
log.debug("Unable to open torrent file: %s", e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if info.info_hash in self.files:
|
||||||
|
log.debug("Trying to add a duplicate torrent!")
|
||||||
|
continue
|
||||||
|
|
||||||
name = "%s (%s)" % (info.name, os.path.split(filename)[-1])
|
name = "%s (%s)" % (info.name, os.path.split(filename)[-1])
|
||||||
new_row = self.torrent_liststore.append(
|
new_row = self.torrent_liststore.append(
|
||||||
[info.info_hash, info.name, filename])
|
[info.info_hash, info.name, filename])
|
||||||
|
@ -219,14 +223,18 @@ class AddTorrentDialog(component.Component):
|
||||||
|
|
||||||
def _on_torrent_changed(self, treeselection):
|
def _on_torrent_changed(self, treeselection):
|
||||||
(model, row) = treeselection.get_selected()
|
(model, row) = treeselection.get_selected()
|
||||||
|
if row is None or not model.iter_is_valid(row):
|
||||||
if row is None:
|
|
||||||
self.files_treestore.clear()
|
self.files_treestore.clear()
|
||||||
|
self.previous_selected_torrent = None
|
||||||
|
return
|
||||||
|
|
||||||
|
if model[row][0] not in self.files:
|
||||||
|
self.files_treestore.clear()
|
||||||
|
self.previous_selected_torrent = None
|
||||||
return
|
return
|
||||||
|
|
||||||
# Save the previous torrents options
|
# Save the previous torrents options
|
||||||
self.save_torrent_options()
|
self.save_torrent_options()
|
||||||
|
|
||||||
# Update files list
|
# Update files list
|
||||||
files_list = self.files[model.get_value(row, 0)]
|
files_list = self.files[model.get_value(row, 0)]
|
||||||
|
|
||||||
|
@ -336,9 +344,9 @@ class AddTorrentDialog(component.Component):
|
||||||
def save_torrent_options(self, row=None):
|
def save_torrent_options(self, row=None):
|
||||||
# Keeps the torrent options dictionary up-to-date with what the user has
|
# Keeps the torrent options dictionary up-to-date with what the user has
|
||||||
# selected.
|
# selected.
|
||||||
if row is None:
|
if row is None and self.previous_selected_torrent and self.torrent_liststore.iter_is_valid(self.previous_selected_torrent):
|
||||||
row = self.previous_selected_torrent
|
row = self.previous_selected_torrent
|
||||||
if row is None or not self.torrent_liststore.iter_is_valid(row):
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
torrent_id = self.torrent_liststore.get_value(row, 0)
|
torrent_id = self.torrent_liststore.get_value(row, 0)
|
||||||
|
@ -376,6 +384,10 @@ class AddTorrentDialog(component.Component):
|
||||||
self.options[torrent_id] = options
|
self.options[torrent_id] = options
|
||||||
|
|
||||||
# Save the file priorities
|
# Save the file priorities
|
||||||
|
(model, srow) = self.listview_torrents.get_selection().get_selected()
|
||||||
|
if srow != row:
|
||||||
|
files_priorities = [1] * len(self.files[torrent_id])
|
||||||
|
else:
|
||||||
files_priorities = self.build_priorities(
|
files_priorities = self.build_priorities(
|
||||||
self.files_treestore.get_iter_first(), {})
|
self.files_treestore.get_iter_first(), {})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue