Skip to content

Commit

Permalink
Simplify xpc service acquisition completion handler
Browse files Browse the repository at this point in the history
  • Loading branch information
claucambra committed Jan 30, 2024
1 parent 326cdb0 commit d13c543
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/gui/macOS/fileproviderxpc_mac_utils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
for (NSFileProviderDomain *const domain in domains) {
qCInfo(lcFileProviderXPCUtils) << "Got domain" << domain.identifier;
NSFileProviderManager *const manager = [NSFileProviderManager managerForDomain:domain];
[manager retain];
[managers addObject:manager];
}

Expand All @@ -68,23 +69,18 @@
dispatch_group_t group = dispatch_group_create();

for (NSFileProviderManager *const manager in managers) {
__block NSFileProviderService *acquiredService;
dispatch_group_enter(group);
[manager getServiceWithName:nsClientCommunicationServiceName
itemIdentifier:NSFileProviderRootContainerItemIdentifier
completionHandler:^(NSFileProviderService *const service, NSError *const error) {
if (error != nil) {
qCWarning(lcFileProviderXPCUtils) << "Error getting file provider service" << error;
dispatch_group_leave(group);
return;
} else if (service == nil) {
qCWarning(lcFileProviderXPCUtils) << "Service is nil";
dispatch_group_leave(group);
return;
} else {
[service retain];
[fpServices addObject:@{service.name: service}];
}

[service retain];
[fpServices addObject:@{acquiredService.name: acquiredService}];
dispatch_group_leave(group);
}];
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
Expand Down

0 comments on commit d13c543

Please sign in to comment.