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

protect some additional dictionaries #2339

Merged
merged 5 commits into from May 24, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepCore/QSObject.h
Expand Up @@ -63,7 +63,7 @@ typedef struct _QSObjectFlags {

NSMutableDictionary * meta; //Name, Label, Type, Identifier, Source, embedded details
NSMutableDictionary * data; //Data or typed dictionary (multiTyped Object)
NSMutableDictionary * cache; //Icons, children, alias data,
QSThreadSafeMutableDictionary *cache; //Icons, children, alias data,
QSObjectFlags flags;
NSTimeInterval lastAccess;
}
Expand Down
20 changes: 9 additions & 11 deletions Quicksilver/Code-QuickStepCore/QSObject.m
Expand Up @@ -67,6 +67,7 @@ - (id)init {

data = [NSMutableDictionary dictionaryWithCapacity:0];
meta = [NSMutableDictionary dictionaryWithCapacity:0];
cache = [QSThreadSafeMutableDictionary dictionaryWithCapacity:0];
name = nil;
label = nil;
icon = nil;
Expand Down Expand Up @@ -441,15 +442,13 @@ - (void)setObject:(id)object forCache:(id)aKey {
if (!aKey) {
return;
}
@synchronized([self cache]) {
if (object) {
if (object != [[self cache] objectForKey:aKey]) {
[[self cache] setObject:object forKey:aKey];
}
} else {
[[self cache] removeObjectForKey:aKey];
}
}
if (object) {
if (object != [[self cache] objectForKey:aKey]) {
[[self cache] setObject:object forKey:aKey];
}
} else {
[[self cache] removeObjectForKey:aKey];
}
}

- (id)objectForMeta:(id)aKey {
Expand All @@ -470,12 +469,11 @@ - (void)setObject:(id)object forMeta:(id)aKey {
}

- (NSMutableDictionary *)cache {
if (!cache) [self setCache:[NSMutableDictionary dictionaryWithCapacity:1]];
return cache;
}
- (void)setCache:(NSMutableDictionary *)aCache {
if (cache != aCache) {
cache = aCache;
cache = [QSThreadSafeMutableDictionary dictionaryWithDictionary:aCache];
}
}

Expand Down
4 changes: 2 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSRegistry.h
Expand Up @@ -17,10 +17,10 @@ extern QSRegistry *QSReg; // Registry shared instance
@interface QSRegistry : NSObject {
NSMutableDictionary *classRegistry; //Dictionaries of registered class names for specific purposes
NSMutableDictionary *tableInstances; //Dictionaries of class instances, only maintained for requested types
NSMutableDictionary *classInstances; //Dictionary of class instances by name
QSThreadSafeMutableDictionary *classInstances; //Dictionary of class instances by name
NSMutableDictionary *classBundles; //Bundles containing registered classes
NSMutableDictionary *identifierBundles; //Bundles by identifier
NSMutableDictionary *prefInstances; //Preferred Instances of tables
QSThreadSafeMutableDictionary *prefInstances; //Preferred Instances of tables
NSMutableDictionary *infoRegistry; //Plists containing various plugin information

BOOL initialLoadComplete;
Expand Down
4 changes: 2 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSRegistry.m
Expand Up @@ -32,10 +32,10 @@ - (id)init {
if (self = [super init]) {
classRegistry = [[NSMutableDictionary alloc] init];
tableInstances = [[NSMutableDictionary alloc] init];
classInstances = [[NSMutableDictionary alloc] init];
classInstances = [[QSThreadSafeMutableDictionary alloc] init];
classBundles = [[NSMutableDictionary alloc] init];
identifierBundles = [[NSMutableDictionary alloc] init];
prefInstances = [[NSMutableDictionary alloc] init];
prefInstances = [[QSThreadSafeMutableDictionary alloc] init];
infoRegistry = [[NSMutableDictionary alloc] init];
[self objectSources];
[self objectHandlers];
Expand Down