From f2f73b85393e55cb7ce0194a2877b5e382d35d1e Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sun, 30 Sep 2007 05:33:53 +0000 Subject: [PATCH] Fix exception when removing multiple torrents at once. Updated TODO. --- TODO | 2 -- deluge/core/core.py | 9 +++++---- deluge/core/torrent.py | 6 +++--- deluge/core/torrentmanager.py | 4 ++-- deluge/ui/gtkui/torrentdetails.py | 6 +++++- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index fdb76310f..08d7e3bad 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -* Have peer numbers show what we receive from tracker_reply_alert * Have the ui better handle not being able to connect to the daemon. * Tray locking and other tray options (close to tray, start in tray..) * Add state saving to listview.. this includes saving column size and position. @@ -14,7 +13,6 @@ * Change the menubar.py gtkui component to menus.py and add support for plugins to add menuitems to the torrentmenu in an easy way. * Add the tracker responses to the torrent details -* Fast resume saving * Restart daemon function * Sync the details pane to current trunk * Automatically save torrent state every ~5 minutes, much like how diff --git a/deluge/core/core.py b/deluge/core/core.py index 3ae8b74e0..e4f99b602 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -151,8 +151,7 @@ class Core(dbus.service.Object): log.info("Shutting down core..") self.loop.quit() self.plugins.shutdown() - del self.plugins - del self.torrents + self.torrents.shutdown() # Make sure the config file has been saved self.config.save() del self.config @@ -265,7 +264,9 @@ class Core(dbus.service.Object): status = self.torrents[torrent_id].get_status(nkeys) except KeyError: # The torrent_id is not found in the torrentmanager, so return None - 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())) @@ -486,4 +487,4 @@ class Core(dbus.service.Object): # Write the fastresume file self.torrents.write_fastresume(torrent_id) # Emit torrent_paused signal - self.torrent_paused(torrent_id) + self.torrent_paused(torrent_id) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 0b58bf029..cbe017236 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -49,7 +49,7 @@ class Torrent: self.total_uploaded = 0 # Set the allocation mode self.compact = compact - + def get_state(self): """Returns the state of this torrent for saving to the session state""" return (self.torrent_id, self.filename, self.compact) @@ -94,12 +94,12 @@ class Torrent: progress = status.progress*100 # Get the total number of seeds and peers - if status.num_complete is -1: + if status.num_complete == -1: total_seeds = status.num_seeds else: total_seeds = status.num_complete - if status.num_incomplete is -1: + if status.num_incomplete == -1: total_peers = status.num_peers - status.num_seeds else: total_peers = status.num_incomplete diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index b8985665a..c02e332c0 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -78,8 +78,8 @@ class TorrentManager: self.on_set_max_connections_per_torrent) self.config.register_set_function("max_upload_slots_per_torrent", self.on_set_max_upload_slots_per_torrent) - - def __del__(self): + + def shutdown(self): log.debug("TorrentManager shutting down..") # Save state on shutdown self.save_state() diff --git a/deluge/ui/gtkui/torrentdetails.py b/deluge/ui/gtkui/torrentdetails.py index f7fd2e0c2..7eaffde3d 100644 --- a/deluge/ui/gtkui/torrentdetails.py +++ b/deluge/ui/gtkui/torrentdetails.py @@ -96,7 +96,11 @@ class TorrentDetails: status = functions.get_torrent_status(self.core, selected, status_keys) - + + # Check to see if we got valid data from the core + if status is None: + return + # We need to adjust the value core gives us for progress progress = status["progress"]/100 self.progress_bar.set_fraction(progress)