mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 19:44:52 +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
09f9c042e4
commit
d44a479177
2 changed files with 21 additions and 7 deletions
|
@ -7,6 +7,8 @@ Deluge 1.1.1 - (In Development)
|
|||
* Fix remembering sorted column in the torrent list
|
||||
* Fix saving Files tab and Peers tab state
|
||||
* Disable popup notification in preferences on Windows
|
||||
* Fix crashing in AddTorrentDialog when removing torrents from the list
|
||||
* Do not allow duplicate torrents in the AddTorrentDialog
|
||||
|
||||
Misc:
|
||||
* Fix bdecoding some torrent files
|
||||
|
|
|
@ -181,6 +181,10 @@ class AddTorrentDialog(component.Component):
|
|||
log.debug("Unable to open torrent file: %s", e)
|
||||
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])
|
||||
new_row = self.torrent_liststore.append(
|
||||
[info.info_hash, info.name, filename])
|
||||
|
@ -219,14 +223,18 @@ class AddTorrentDialog(component.Component):
|
|||
|
||||
def _on_torrent_changed(self, treeselection):
|
||||
(model, row) = treeselection.get_selected()
|
||||
|
||||
if row is None:
|
||||
if row is None or not model.iter_is_valid(row):
|
||||
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
|
||||
|
||||
# Save the previous torrents options
|
||||
self.save_torrent_options()
|
||||
|
||||
# Update files list
|
||||
files_list = self.files[model.get_value(row, 0)]
|
||||
|
||||
|
@ -336,9 +344,9 @@ class AddTorrentDialog(component.Component):
|
|||
def save_torrent_options(self, row=None):
|
||||
# Keeps the torrent options dictionary up-to-date with what the user has
|
||||
# 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
|
||||
if row is None or not self.torrent_liststore.iter_is_valid(row):
|
||||
else:
|
||||
return
|
||||
|
||||
torrent_id = self.torrent_liststore.get_value(row, 0)
|
||||
|
@ -376,8 +384,12 @@ class AddTorrentDialog(component.Component):
|
|||
self.options[torrent_id] = options
|
||||
|
||||
# Save the file priorities
|
||||
files_priorities = self.build_priorities(
|
||||
self.files_treestore.get_iter_first(), {})
|
||||
(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(
|
||||
self.files_treestore.get_iter_first(), {})
|
||||
|
||||
if len(files_priorities) > 0:
|
||||
for i, file_dict in enumerate(self.files[torrent_id]):
|
||||
|
|
Loading…
Add table
Reference in a new issue