Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash Fixes #1015

Merged
merged 4 commits into from
Aug 14, 2012
Merged
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
77 changes: 37 additions & 40 deletions Quicksilver/Code-QuickStepCore/QSCatalogEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,8 @@ - (void)saveIndex {

// Lock the 'contents' mutablearray so that it cannot be changed whilst it's being written to file
@synchronized(contents) {
NSArray *writeArray = [[[self contents] arrayByPerformingSelector:@selector(dictionaryRepresentation)] copy];
NSArray *writeArray = [contents arrayByPerformingSelector:@selector(dictionaryRepresentation)];
[writeArray writeToFile:[[path stringByAppendingPathComponent:key] stringByAppendingPathExtension:@"qsindex"] atomically:YES];
[writeArray release];
}
}

Expand Down Expand Up @@ -476,27 +475,18 @@ - (id)source {
}

- (NSArray *)scannedObjects {
if (isScanning) {
#ifdef DEBUG
if (VERBOSE) NSLog(@"%@ is already being scanned", [self name]);
#endif
return nil;
} else {
[self setIsScanning:YES];
NSArray *itemContents = nil;
@autoreleasepool {
@try {
QSObjectSource *source = [self source];
itemContents = [[source objectsForEntry:info] retain];
}
@catch (NSException *exception) {
NSLog(@"An error ocurred while scanning \"%@\": %@", [self name], exception);
[exception printStackTrace];
}
NSArray *itemContents = nil;
@autoreleasepool {
@try {
QSObjectSource *source = [self source];
itemContents = [[source objectsForEntry:info] retain];
}
[self setIsScanning:NO];
return [itemContents autorelease];
}
@catch (NSException *exception) {
NSLog(@"An error ocurred while scanning \"%@\": %@", [self name], exception);
[exception printStackTrace];
}
}
return [itemContents autorelease];
}

- (BOOL)canBeIndexed {
Expand All @@ -505,25 +495,32 @@ - (BOOL)canBeIndexed {
}

- (NSArray *)scanAndCache {
NSString *ID = [self identifier];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:QSCatalogEntryIsIndexing object:self];
NSArray *itemContents = [self scannedObjects];
if (isScanning) {
#ifdef DEBUG
if (VERBOSE) NSLog(@"%@ is already being scanned", [self name]);
#endif
return nil;
} else {
[self setIsScanning:YES];
NSString *ID = [self identifier];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:QSCatalogEntryIsIndexing object:self];
NSArray *itemContents = [self scannedObjects];
if (itemContents && ID) {
[self setContents:itemContents];
QSObjectSource *source = [self source];
if (![source respondsToSelector:@selector(entryCanBeIndexed:)] || [source entryCanBeIndexed:[self info]]) {
[self saveIndex];
} else {
// NSLog(@"not caching %@", [self name]);
}
} else if (ID) {
[self setContents:nil]; //[catalogArrays removeObjectForKey:ID];
}
[self willChangeValueForKey:@"self"];
[self didChangeValueForKey:@"self"];
[nc postNotificationName:QSCatalogEntryIndexed object:self];
return itemContents;
[self setContents:itemContents];
QSObjectSource *source = [self source];
if (![source respondsToSelector:@selector(entryCanBeIndexed:)] || [source entryCanBeIndexed:[self info]]) {
[self saveIndex];
}
} else if (ID) {
[self setContents:nil];
}
[self willChangeValueForKey:@"self"];
[self didChangeValueForKey:@"self"];
[nc postNotificationName:QSCatalogEntryIndexed object:self];
[self setIsScanning:NO];
return itemContents;
}
}

- (void)scanForcedInThread:(NSNumber *)force {
Expand Down
5 changes: 3 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSObject_PropertyList.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ - (id)initWithDictionary:(NSDictionary *)dictionary {
}

- (NSDictionary *)dictionaryRepresentation {
// copies of data and meta are made to avoid them being mutated down the line
return [NSDictionary dictionaryWithObjectsAndKeys:
data, kData,
meta, kMeta,
[[data copy] autorelease], kData,
[[meta copy] autorelease], kMeta,
NSStringFromClass([self class]), kQSObjectClass,
nil];
}
Expand Down