Skip to content

Commit 46b5f5e

Browse files
rickyznikitabobko
authored andcommitted
Explicitly unregister hotkeys when resetting hotkeys
We cannot always rely on destruction of the HotKey object to trigger unregistration because we might be running inside a hotkey handler that is keeping its HotKey object alive. _fixes #1231
1 parent a8cd536 commit 46b5f5e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/AppBundle/config/HotkeyBinding.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import TOMLKit
77
@MainActor private var hotkeys: [String: HotKey] = [:]
88

99
@MainActor func resetHotKeys() {
10+
// Explicitly unregister all hotkeys. We cannot always rely on destruction of the HotKey object to trigger
11+
// unregistration because we might be running inside a hotkey handler that is keeping its HotKey object alive.
12+
for (_, key) in hotkeys {
13+
key.isEnabled = false
14+
}
1015
hotkeys = [:]
1116
}
1217

0 commit comments

Comments
 (0)