fix: crash if accessibility permission is granted then removed quickly

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-07-30 03:44:38 +09:00
1 parent de81b27fc3
commit 0bca1e0869
1 file changed
+3 -1
+3 -1
View File
@@ -19,7 +19,9 @@ private func observe_() {
eventsOfInterest: eventMask,
callback: keyboardHandler,
userInfo: nil)
let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0)
// permission can have been removed before SystemPermissions timer triggers, thus we check and restart if needed
if eventTap == nil { App.app.restart() }
let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)
CFRunLoopAddSource(BackgroundWork.keyboardEventsThread.runLoop, runLoopSource, .commonModes)
}