Skip to content

Commit

Permalink
Perform scanning on a background queue so that the GUI doesn't lock a…
Browse files Browse the repository at this point in the history
…t startup.
  • Loading branch information
tiennou committed Jan 21, 2013
1 parent 95a66b3 commit bcde11b
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Quicksilver/Code-QuickStepCore/QSLibrarian.m
Expand Up @@ -539,25 +539,27 @@ - (void)scanCatalogIgnoringIndexes:(BOOL)force {
return;
}

@autoreleasepool {
[scanTask setStatus:@"Catalog Rescan"];
[scanTask startTask:self];
[scanTask setProgress:-1];
scannerCount++;
NSArray *children = [catalog deepChildrenWithGroups:NO leaves:YES disabled:NO];
NSUInteger i;
NSUInteger c = [children count];
for (i = 0; i<c; i++) {
[scanTask setProgress:(CGFloat) i/c];
[[children objectAtIndex:i] scanForced:force];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
@autoreleasepool {
[scanTask setStatus:@"Catalog Rescan"];
[scanTask startTask:self];
[scanTask setProgress:-1];
scannerCount++;
NSArray *children = [catalog deepChildrenWithGroups:NO leaves:YES disabled:NO];
NSUInteger i;
NSUInteger c = [children count];
for (i = 0; i<c; i++) {
[scanTask setProgress:(CGFloat) i/c];
[[children objectAtIndex:i] scanForced:force];
}

[scanTask setProgress:1.0];
[scanTask stopTask:self];

[[NSNotificationCenter defaultCenter] postNotificationName:QSCatalogIndexingCompleted object:nil];
scannerCount--;
}

[scanTask setProgress:1.0];
[scanTask stopTask:self];

[[NSNotificationCenter defaultCenter] postNotificationName:QSCatalogIndexingCompleted object:nil];
scannerCount--;
}
});
}


Expand Down

0 comments on commit bcde11b

Please sign in to comment.