From eb7db72965a5262f714627e857b8f4241ab645e5 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Fri, 14 Sep 2007 19:21:55 +0000 Subject: [PATCH] try to catch windows shutdown so we exit properly and dont lose data --- src/interface.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/interface.py b/src/interface.py index 87a5cdce6..f4e06e1b0 100644 --- a/src/interface.py +++ b/src/interface.py @@ -149,6 +149,14 @@ class DelugeGTK: import platform if not platform.system() in ('Windows', 'Microsoft'): signal.signal(signal.SIGHUP, self.manager.quit) + else: + from win32api import SetConsoleCtrlHandler + from win32con import CTRL_CLOSE_EVENT + def win_handler(self, ctrl_type): + if ctrl_type == CTRL_CLOSE_EVENT: + self.shutdown() + SetConsoleCtrlHandler(win_handler) + self.dht_timer = 0 self.dht_skip = False