From d44a4791773a1efa70ef1970ff2cbd648eb46454 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 17 Jan 2009 21:58:02 +0000 Subject: Fix crashing in AddTorrentDialog when removing torrents from the list Do not allow duplicate torrents in the AddTorrentDialog --- ChangeLog | 2 ++ deluge/ui/gtkui/addtorrentdialog.py | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index cea223d06..e30456d9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 91b522e93..d2eae7c2e 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -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 or not model.iter_is_valid(row): + self.files_treestore.clear() + self.previous_selected_torrent = None + return - if row is None: + 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]): -- cgit