From 28169cc40446cd6a8f4d60cccedf43f7d3dac44a Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Tue, 6 Sep 2016 12:41:02 +0100 Subject: [PATCH] Clean up hotkey thread on exit on Windows --- hotkey.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hotkey.py b/hotkey.py index 3ba0ceda..becc2f00 100644 --- a/hotkey.py +++ b/hotkey.py @@ -9,7 +9,6 @@ from config import config if platform == 'darwin': - import threading import objc from AppKit import NSApplication, NSWorkspace, NSBeep, NSSound, NSEvent, NSKeyDown, NSKeyUp, NSFlagsChanged, NSKeyDownMask, NSFlagsChangedMask, NSShiftKeyMask, NSControlKeyMask, NSAlternateKeyMask, NSCommandKeyMask, NSNumericPadKeyMask, NSDeviceIndependentModifierFlagsMask, NSF1FunctionKey, NSF35FunctionKey, NSDeleteFunctionKey, NSClearLineFunctionKey @@ -180,6 +179,7 @@ if platform == 'darwin': elif platform == 'win32': + import atexit import ctypes from ctypes.wintypes import * import threading @@ -285,6 +285,7 @@ elif platform == 'win32': self.thread = None self.snd_good = open(join(config.respath, 'snd_good.wav'), 'rb').read() self.snd_bad = open(join(config.respath, 'snd_bad.wav'), 'rb').read() + atexit.register(self.unregister) def register(self, root, keycode, modifiers): self.root = root