mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-06 10:23:06 +03:00
hotkey: Avoid event_generate() calls during shutdown
This commit is contained in:
parent
cb9bd30a05
commit
6cdc1dc20c
10
hotkey.py
10
hotkey.py
@ -92,11 +92,15 @@ if platform == 'darwin':
|
|||||||
self.observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, self._handler)
|
self.observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, self._handler)
|
||||||
|
|
||||||
def _poll(self):
|
def _poll(self):
|
||||||
|
if config.shutting_down():
|
||||||
|
return
|
||||||
|
|
||||||
# No way of signalling to Tkinter from within the callback handler block that doesn't
|
# No way of signalling to Tkinter from within the callback handler block that doesn't
|
||||||
# cause Python to crash, so poll.
|
# cause Python to crash, so poll.
|
||||||
if self.activated:
|
if self.activated:
|
||||||
self.activated = False
|
self.activated = False
|
||||||
self.root.event_generate('<<Invoke>>', when="tail")
|
self.root.event_generate('<<Invoke>>', when="tail")
|
||||||
|
|
||||||
if self.keycode or self.modifiers:
|
if self.keycode or self.modifiers:
|
||||||
self.root.after(HotkeyMgr.POLL, self._poll)
|
self.root.after(HotkeyMgr.POLL, self._poll)
|
||||||
|
|
||||||
@ -123,6 +127,9 @@ if platform == 'darwin':
|
|||||||
self.acquire_state = HotkeyMgr.ACQUIRE_INACTIVE
|
self.acquire_state = HotkeyMgr.ACQUIRE_INACTIVE
|
||||||
|
|
||||||
def _acquire_poll(self):
|
def _acquire_poll(self):
|
||||||
|
if config.shutting_down():
|
||||||
|
return
|
||||||
|
|
||||||
# No way of signalling to Tkinter from within the monkey-patched event handler that doesn't
|
# No way of signalling to Tkinter from within the monkey-patched event handler that doesn't
|
||||||
# cause Python to crash, so poll.
|
# cause Python to crash, so poll.
|
||||||
if self.acquire_state:
|
if self.acquire_state:
|
||||||
@ -316,7 +323,8 @@ elif platform == 'win32':
|
|||||||
while GetMessage(ctypes.byref(msg), None, 0, 0) != 0:
|
while GetMessage(ctypes.byref(msg), None, 0, 0) != 0:
|
||||||
if msg.message == WM_HOTKEY:
|
if msg.message == WM_HOTKEY:
|
||||||
if config.getint('hotkey_always') or WindowTitle(GetForegroundWindow()).startswith('Elite - Dangerous'):
|
if config.getint('hotkey_always') or WindowTitle(GetForegroundWindow()).startswith('Elite - Dangerous'):
|
||||||
self.root.event_generate('<<Invoke>>', when="tail")
|
if not config.shutting_down():
|
||||||
|
self.root.event_generate('<<Invoke>>', when="tail")
|
||||||
else:
|
else:
|
||||||
# Pass the key on
|
# Pass the key on
|
||||||
UnregisterHotKey(None, 1)
|
UnregisterHotKey(None, 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user