From 40e4fb9b8e939922499c990db559bb4584dbce20 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 19 Feb 2012 16:44:12 +0000 Subject: [PATCH] Catch and log ReactorNotRunning when stopping reactor in gtk --- deluge/ui/gtkui/gtkui.py | 2 +- deluge/ui/gtkui/ipcinterface.py | 2 +- deluge/ui/gtkui/mainwindow.py | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index f5eea4c31..9d64340bb 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -274,7 +274,7 @@ class GtkUI(object): def on_dialog_response(response): if response != gtk.RESPONSE_YES: # The user does not want to turn Classic Mode off, so just quit - reactor.stop() + self.mainwindow.quit() return # Turning off classic_mode self.config["classic_mode"] = False diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtkui/ipcinterface.py index aefdf4973..15c2b6872 100644 --- a/deluge/ui/gtkui/ipcinterface.py +++ b/deluge/ui/gtkui/ipcinterface.py @@ -153,7 +153,7 @@ class IPCInterface(component.Component): def connect_failed(self, args): # This gets called when we're unable to do a connectUNIX to the ipc # socket. We'll delete the lock and socket files and start up Deluge. - #reactor.stop() + socket = os.path.join(deluge.configmanager.get_config_dir("ipc"), "deluge-gtk") if os.path.exists(socket): try: diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 4dcd6c4ec..d491441d0 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -47,6 +47,7 @@ import deluge.component as component from deluge.configmanager import ConfigManager from deluge.ui.gtkui.ipcinterface import process_args from twisted.internet import reactor +from twisted.internet.error import ReactorNotRunning import deluge.common import common @@ -218,7 +219,10 @@ class MainWindow(component.Component): """ if shutdown: def on_daemon_shutdown(result): - reactor.stop() + try: + reactor.stop() + except ReactorNotRunning: + log.debug("Attempted to stop the reactor but it is not running...") client.daemon.shutdown().addCallback(on_daemon_shutdown) return if client.is_classicmode():