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
2 changes: 1 addition & 1 deletion Source/CFRunLoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ CFRunLoopSourceRemoveInvalidated(const void *key, const void *value, void *sourc
{
GSRunLoopContextRef ctxt = (GSRunLoopContextRef) value;
CFIndex idx = CFArrayGetFirstIndexOfValue(ctxt->sources0,
CFRangeMake(0, CFArrayGetCount(ctxt->timers)),
CFRangeMake(0, CFArrayGetCount(ctxt->sources0)),
(CFRunLoopSourceRef) source);

if (idx != -1)
Expand Down
32 changes: 32 additions & 0 deletions Tests/CFRunLoop/source_invalidate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "CoreFoundation/CFRunLoop.h"
#include "../CFTesting.h"
#include <string.h>

/* Removing an invalidated CFRunLoopSource from the run loop. */

static void perform (void *info)
{
}

int main (void)
{
CFRunLoopRef rl;
CFRunLoopSourceContext ctx;
CFRunLoopSourceRef src;

rl = CFRunLoopGetCurrent ();
memset (&ctx, 0, sizeof (ctx));
ctx.perform = perform;
src = CFRunLoopSourceCreate (NULL, 0, &ctx);
CFRunLoopAddSource (rl, src, kCFRunLoopDefaultMode);
PASS_CF(CFRunLoopContainsSource (rl, src, kCFRunLoopDefaultMode) == true,
"Source is in the run loop after being added.");

/* No timers are registered. */
CFRunLoopSourceInvalidate (src);
PASS_CF(CFRunLoopContainsSource (rl, src, kCFRunLoopDefaultMode) == false,
"Invalidated source is removed from the run loop.");

CFRelease (src);
return 0;
}
Loading