From de79bba5405c5deb1dc5d527c4b57be33b55da61 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 22 Jun 2010 18:24:27 -0700 Subject: [PATCH] Fix #1302 an uncaught exception in an state_changed event handler in SessionProxy was preventing the TorrentManager's stop method from properly saving all the resume data. --- deluge/ui/gtkui/gtkui.py | 6 ------ deluge/ui/gtkui/menubar.py | 2 -- deluge/ui/sessionproxy.py | 6 +++++- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index f784bd3bb..bfec91b3a 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -252,12 +252,6 @@ class GtkUI(object): # Shutdown all components component.shutdown() - if self.started_in_classic: - try: - client.daemon.shutdown() - except: - pass - # Make sure the config is saved. self.config.save() diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 1fe549afa..7f16b1132 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -260,8 +260,6 @@ class MenuBar(component.Component): def on_menuitem_quit_activate(self, data=None): log.debug("on_menuitem_quit_activate") - if self.config["classic_mode"] and client.is_classicmode(): - client.daemon.shutdown() self.window.quit() ## Edit Menu ## diff --git a/deluge/ui/sessionproxy.py b/deluge/ui/sessionproxy.py index 42451ae65..718c95104 100644 --- a/deluge/ui/sessionproxy.py +++ b/deluge/ui/sessionproxy.py @@ -76,6 +76,9 @@ class SessionProxy(component.Component): return client.core.get_torrents_status({}, [], True).addCallback(on_torrent_status) def stop(self): + client.deregister_event_handler("TorrentStateChangedEvent", self.on_torrent_state_changed) + client.deregister_event_handler("TorrentRemovedEvent", self.on_torrent_removed) + client.deregister_event_handler("TorrentAddedEvent", self.on_torrent_added) self.torrents = {} def create_status_dict(self, torrent_ids, keys): @@ -197,7 +200,8 @@ class SessionProxy(component.Component): return d.addCallback(on_status, None, keys) def on_torrent_state_changed(self, torrent_id, state): - self.torrents[torrent_id][1]["state"] = state + if torrent_id in self.torrents: + self.torrents[torrent_id][1]["state"] = state def on_torrent_added(self, torrent_id): self.torrents[torrent_id] = [time.time() - self.cache_time - 1, {}]