Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Source/CFRunLoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1845,8 +1845,8 @@ CFRunLoopTimerSetNextFireDate (CFRunLoopTimerRef timer,
}

timer->_nextFireDate = fireDate;
// Wake up the runloop so that it can recalculate the next timer date
// but since timers should be planned on current runloop only (NSTimer
// says so), this may not be necessary.
CFRunLoopWakeUp(timer->_runloop);
// Wake up the runloop so that it can recalculate the next timer date,
// but only if the timer has been added to one.
if (timer->_runloop != NULL)
CFRunLoopWakeUp(timer->_runloop);
}
20 changes: 20 additions & 0 deletions Tests/CFRunLoop/timer_setfiredate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "CoreFoundation/CFRunLoop.h"
#include "../CFTesting.h"

static void
fire (CFRunLoopTimerRef t, void *info)
{
}

int main (void)
{
CFRunLoopTimerRef t = CFRunLoopTimerCreate (NULL, 100.0, 5.0, 0, 0,
fire, NULL);

CFRunLoopTimerSetNextFireDate (t, 250.0);
PASS_CF (CFRunLoopTimerGetNextFireDate (t) == 250.0,
"Setting the fire date of a timer not in a run loop updates it.");

CFRelease (t);
return 0;
}
Loading