1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 00:58:37 +00:00

CustomButtonTouchBarItem: try to fix strange app hanging

This commit is contained in:
bobrosoft 2019-08-02 14:50:55 +02:00
parent 11530ef180
commit 229c55c367

View File

@ -190,9 +190,9 @@ class LongPressGestureRecognizer: NSPressGestureRecognizer {
let touches = event.touches(for: self.view!)
if touches.count == 1 { // to prevent it for built-in two/three-finger gestures
timer = Timer.scheduledTimer(withTimeInterval: recognizeTimeout, repeats: false) { _ in
if let target = self.target, let action = self.action {
target.performSelector(inBackground: action, with: self)
timer = Timer.scheduledTimer(withTimeInterval: recognizeTimeout, repeats: false) { [weak self] _ in
if let _self = self, let target = self?.target, let action = self?.action {
target.performSelector(onMainThread: action, with: _self, waitUntilDone: false)
HapticFeedback.shared.tap(strong: 6)
}
}
@ -222,6 +222,10 @@ class LongPressGestureRecognizer: NSPressGestureRecognizer {
self.timer = nil
}
}
deinit {
timerInvalidate()
}
}
extension String {