Skip to content

Commit af73f1c

Browse files
committed
Mark event monitor properties as nonisolated(unsafe)
The event monitor properties need to be accessible from nonisolated stop methods that are called from deinit. Marking them as nonisolated(unsafe) is safe because: - They are opaque tokens from NSEvent.addMonitorForEvents - NSEvent.removeMonitor is thread-safe - We only read them to pass to removeMonitor This resolves the MainActor isolation compilation errors.
1 parent d310b6a commit af73f1c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/ClickIt/Lite/SimpleHotkeyManager.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class SimpleHotkeyManager {
1515

1616
// MARK: - Properties
1717

18-
private var globalMonitor: Any?
19-
private var localMonitor: Any?
18+
nonisolated(unsafe) private var globalMonitor: Any?
19+
nonisolated(unsafe) private var localMonitor: Any?
2020
private var onEmergencyStop: (() -> Void)?
2121

22-
private var globalMouseMonitor: Any?
23-
private var localMouseMonitor: Any?
22+
nonisolated(unsafe) private var globalMouseMonitor: Any?
23+
nonisolated(unsafe) private var localMouseMonitor: Any?
2424
private var onRightMouseClick: (() -> Void)?
2525
private var lastClickTime: TimeInterval = 0
2626
private let clickDebounceInterval: TimeInterval = 0.1

0 commit comments

Comments
 (0)