From f1936feefd243db728928fe1577e412d2e816062 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 16 Nov 2016 09:56:00 +0000 Subject: [PATCH] Fix a regression in the preceeding regresion fix for hs.timer. We now store the requested interval in HSTimer since NSTimer can't reliably tell us what it is/was --- extensions/timer/internal.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/timer/internal.m b/extensions/timer/internal.m index d2f5796ec..e4441dba2 100644 --- a/extensions/timer/internal.m +++ b/extensions/timer/internal.m @@ -16,6 +16,7 @@ @interface HSTimer : NSObject @property int fnRef; @property BOOL continueOnError; @property BOOL repeats; +@property NSTimeInterval interval; - (void)create:(NSTimeInterval)interval repeat:(BOOL)repeat; - (void)callback:(NSTimer *)timer; @@ -53,7 +54,7 @@ - (void)callback:(NSTimer *)timer { if (!self.continueOnError) { // some details about the timer to help identify which one it is: [skin logBreadcrumb:@"hs.timer callback failed. The timer has been stopped to prevent repeated notifications of the error."]; - [skin logBreadcrumb:[NSString stringWithFormat:@" timer details: %s repeating, every %f seconds, next scheduled at %@", CFRunLoopTimerDoesRepeat((__bridge CFRunLoopTimerRef)timer) ? "is" : "is not", timer.timeInterval, timer.fireDate]]; + [skin logBreadcrumb:[NSString stringWithFormat:@" timer details: %s repeating, every %f seconds, next scheduled at %@", CFRunLoopTimerDoesRepeat((__bridge CFRunLoopTimerRef)timer) ? "is" : "is not", self.interval, timer.fireDate]]; [self.t invalidate]; } } @@ -66,10 +67,10 @@ - (BOOL)isRunning { - (void)start { if (!self.t.isValid) { // We've previously been stopped, which means the NSTimer is invalid, so recreate it - [self create:self.t.timeInterval repeat:self.repeats]; + [self create:self.interval repeat:self.repeats]; } - [self setNextTrigger:self.t.timeInterval]; + [self setNextTrigger:self.interval]; [[NSRunLoop currentRunLoop] addTimer:self.t forMode:NSDefaultRunLoopMode]; } @@ -104,6 +105,7 @@ - (void)trigger { timer.fnRef = callbackRef; timer.continueOnError = continueOnError; timer.repeats = repeat; + timer.interval = interval; [timer create:interval repeat:repeat]; return timer;