replace C11 atomics with dispatch_group_t to fix undeclared identifier errors
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/2f0107b0-a6e4-447c-8178-60d65038df4b Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
parent
983185cc62
commit
d3b12031bd
1 changed files with 24 additions and 26 deletions
|
|
@ -1759,19 +1759,20 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
|||
}
|
||||
char *mt = _glfw_strdup(mime);
|
||||
NSMutableArray *collected_urls = [[NSMutableArray alloc] init];
|
||||
_Atomic(NSInteger) *pending = (_Atomic(NSInteger) *)malloc(sizeof(_Atomic(NSInteger)));
|
||||
atomic_init(pending, (NSInteger)[file_receivers count]);
|
||||
dispatch_group_t group = dispatch_group_create();
|
||||
NSOperationQueue *opQueue = [[NSOperationQueue alloc] init];
|
||||
opQueue.maxConcurrentOperationCount = 1; // serial: safe to append to collected_urls
|
||||
for (NSFilePromiseReceiver *receiver in file_receivers) {
|
||||
dispatch_group_enter(group);
|
||||
[receiver receivePromisedFilesAtDestination:tmpDirURL options:@{}
|
||||
operationQueue:opQueue
|
||||
reader:^(NSURL *fileURL, NSError *errorOrNil) {
|
||||
if (!errorOrNil && fileURL) [collected_urls addObject:fileURL];
|
||||
if (atomic_fetch_sub_explicit(pending, 1, memory_order_acq_rel) == 1) {
|
||||
// All file promises resolved; build uri-list on the main thread
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
free(pending);
|
||||
dispatch_group_leave(group);
|
||||
}];
|
||||
}
|
||||
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
||||
dispatch_release(group);
|
||||
_GLFWwindow *w = _glfwWindowForId(wid);
|
||||
if (w && w->ns.drop_data.file_promise_mapping) {
|
||||
if (w->ns.drop_data.data_mapping == nil)
|
||||
|
|
@ -1791,9 +1792,6 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
|||
[opQueue release];
|
||||
free(mt);
|
||||
});
|
||||
}
|
||||
}];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} else if (strcmp(mime, "text/plain") == 0 || strcmp(mime, "text/plain;charset=utf-8") == 0) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue