diff --git a/deluge/core/core.py b/deluge/core/core.py index 43547e6e8..75c4159ec 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -157,7 +157,14 @@ class Core(dbus.service.Object): for key in keys: nkeys.append(str(key)) # Pickle the status dictionary from the torrent - status = self.torrents[torrent_id].get_status(nkeys) + try: + status = self.torrents[torrent_id].get_status(nkeys) + except KeyError: + # The torrent_id is not found in the torrentmanager, so return None + status = None + status.pickle.dumps(status) + return status + # Get the leftover fields and ask the plugin manager to fill them leftover_fields = list(set(nkeys) - set(status.keys())) if len(leftover_fields) > 0: diff --git a/deluge/plugins/queue/queue/core.py b/deluge/plugins/queue/queue/core.py index 568da2e62..a82660b17 100644 --- a/deluge/plugins/queue/queue/core.py +++ b/deluge/plugins/queue/queue/core.py @@ -78,7 +78,10 @@ class Core(dbus.service.Object): ## Status field function ## def status_field_queue(self, torrent_id): - return self.queue[torrent_id]+1 + try: + return self.queue[torrent_id]+1 + except TypeError: + return None ## Queueing functions ## @dbus.service.method(dbus_interface="org.deluge_torrent.Deluge.Queue", diff --git a/deluge/plugins/queue/queue/torrentqueue.py b/deluge/plugins/queue/queue/torrentqueue.py index 75033ef9c..983639d10 100644 --- a/deluge/plugins/queue/queue/torrentqueue.py +++ b/deluge/plugins/queue/queue/torrentqueue.py @@ -44,7 +44,10 @@ class TorrentQueue: def __getitem__(self, torrent_id): """Return the queue position of the torrent_id""" - return self.queue.index(torrent_id) + try: + return self.queue.index(torrent_id) + except ValueError: + return None def load_state(self): """Load the queue state""" diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index b22353f05..1b482b6b8 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -199,8 +199,11 @@ class TorrentView(listview.ListView): def get_selected_torrents(self): """Returns a list of selected torrents or None""" torrent_ids = [] - paths = self.treeview.get_selection().get_selected_rows()[1] - + try: + paths = self.treeview.get_selection().get_selected_rows()[1] + except AttributeError: + # paths is likely None .. so lets return None + return None try: for path in paths: torrent_ids.append(