Fix properly shutting Deluge down when system shuts down

This commit is contained in:
Andrew Resch 2008-08-17 04:51:28 +00:00
parent 477d5c0def
commit e720994f5f
2 changed files with 6 additions and 2 deletions

View File

@ -195,9 +195,11 @@ class Core(
else: else:
from win32api import SetConsoleCtrlHandler from win32api import SetConsoleCtrlHandler
from win32con import CTRL_CLOSE_EVENT from win32con import CTRL_CLOSE_EVENT
from win32con import CTRL_SHUTDOWN_EVENT
result = 0 result = 0
def win_handler(ctrl_type): def win_handler(ctrl_type):
if ctrl_type == CTRL_CLOSE_EVENT: log.debug("ctrl_type: %s", ctrl_type)
if ctrl_type == CTRL_CLOSE_EVENT or ctrl_type == CTRL_SHUTDOWN_EVENT:
self._shutdown() self._shutdown()
result = 1 result = 1
return result return result

View File

@ -151,9 +151,11 @@ class GtkUI:
if deluge.common.windows_check(): if deluge.common.windows_check():
from win32api import SetConsoleCtrlHandler from win32api import SetConsoleCtrlHandler
from win32con import CTRL_CLOSE_EVENT from win32con import CTRL_CLOSE_EVENT
from win32con import CTRL_SHUTDOWN_EVENT
result = 0 result = 0
def win_handler(ctrl_type): def win_handler(ctrl_type):
if ctrl_type == CTRL_CLOSE_EVENT: log.debug("ctrl_type: %s", ctrl_type)
if ctrl_type == CTRL_CLOSE_EVENT or ctrl_type == CTRL_SHUTDOWN_EVENT:
self.shutdown() self.shutdown()
return 1 return 1
SetConsoleCtrlHandler(win_handler) SetConsoleCtrlHandler(win_handler)