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 @@ -1325,7 +1325,7 @@ CFRunLoopCommonModesRemove (CFRunLoopRef rl, CFTypeRef obj)
CFIndex idx;
struct common_mode_info info = { rl, obj, false };
range = CFRangeMake (0, CFArrayGetCount (rl->_commonObjects));
idx = CFArrayContainsValue (rl->_commonObjects, range, obj);
idx = CFArrayGetFirstIndexOfValue (rl->_commonObjects, range, obj);
if (idx != kCFNotFound)
CFArrayRemoveValueAtIndex (rl->_commonObjects, idx);

Expand Down
41 changes: 41 additions & 0 deletions Tests/CFRunLoop/common_remove.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <CoreFoundation/CFRunLoop.h>

#include "../CFTesting.h"
#include <pthread.h>

static void *
body (void *unused)
{
CFRunLoopRef rl;
CFRunLoopSourceContext sc = {0};
CFRunLoopSourceRef src;

rl = CFRunLoopGetCurrent ();
CFRunLoopAddCommonMode (rl, CFSTR ("testCommonMode"));

src = CFRunLoopSourceCreate (NULL, 0, &sc);
CFRunLoopAddSource (rl, src, kCFRunLoopCommonModes);
PASS_CF(CFRunLoopContainsSource (rl, src, kCFRunLoopCommonModes) == true,
"Source is in the common modes after being added.");
PASS_CF(CFRunLoopContainsSource (rl, src, kCFRunLoopDefaultMode) == true,
"Source reaches the default mode after being added to common modes.");

CFRunLoopRemoveSource (rl, src, kCFRunLoopCommonModes);
PASS_CF(CFRunLoopContainsSource (rl, src, kCFRunLoopCommonModes) == false,
"Source is not in the common modes after being removed.");
PASS_CF(CFRunLoopContainsSource (rl, src, kCFRunLoopDefaultMode) == false,
"Source no longer reaches the default mode after common-modes removal.");
PASS_CF(CFRunLoopContainsSource (rl, src, CFSTR ("testCommonMode")) == false,
"Source no longer reaches a registered common mode after removal.");
CFRelease (src);

return NULL;
}

int main (void)
{
pthread_t th;
pthread_create (&th, NULL, body, NULL);
pthread_join (th, NULL);
return 0;
}
Loading