From fc9bc2976f9a3210774323146366cf8c405a1e00 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 15 Nov 2015 12:47:07 +0000 Subject: [PATCH] [GTKUI] Fix open dialogs preventing gtk app closing --- deluge/ui/gtkui/gtkui.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 5c0eeeba4..00a6b3784 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -237,6 +237,8 @@ class GtkUI(object): self.daemon_bps = (0, 0, 0) self.rpc_stats = LoopingCall(self.print_rpc_stats) + # Twisted catches signals to terminate, so have it call a pre_shutdown method. + reactor.addSystemEventTrigger("before", "shutdown", self.pre_shutdown) reactor.callWhenRunning(self._on_reactor_start) # Initialize gdk threading @@ -260,6 +262,10 @@ class GtkUI(object): # Make sure the config is saved. self.config.save() + def pre_shutdown(self, *args, **kwargs): + """Modal dialogs can prevent the application exiting so destroy mainwindow""" + self.mainwindow.window.destroy() + def print_rpc_stats(self): if not client.connected(): return