Skip to content

Commit

Permalink
Merge branch 'master' into triggerNull
Browse files Browse the repository at this point in the history
  • Loading branch information
pjrobertson committed Jul 17, 2011
2 parents ef822d4 + d47cc67 commit 0ed2054
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 23 deletions.
70 changes: 51 additions & 19 deletions Quicksilver/Code-QuickStepCore/QSCommand.m
Expand Up @@ -296,36 +296,68 @@ - (QSAction *)aObject {

- (QSObject *)dObject {
QSObject *object = dObject;
if (!object) {
object = [QSObject objectWithIdentifier:[[self commandDict] objectForKey:@"directID"]];
[self setDirectObject:object];
}
if (!object) {
object = [QSAction actionWithIdentifier:[[self commandDict] objectForKey:@"directID"]];
[self setDirectObject:object];
// If we have the object, do not go through numerous 'if(!object)' before returning
if (object) {
return object;
}

NSDictionary *cmdDict = [self commandDict];
NSString *directID = [cmdDict objectForKey:@"directID"];

if (directID) {
object = [QSObject objectWithIdentifier:directID];
// For cases where the command has a directID/directArchive, but it's corresponding object hasn't already been created (i.e. *not* in the catalog)
if (!object) {
// sniffs the string to create a new object
object = [QSObject objectWithString:directID];
}
}
if (!object) {
if (!object) {
object = [QSObject objectWithDictionary:[[self commandDict] objectForKey:@"directArchive"]];
[self setDirectObject:object];
}

[self setDirectObject:object];

if (!object)
object = [QSObject fileObjectWithPath:[QSRez pathWithLocatorInformation:[[self commandDict] objectForKey:@"directResource"]]];
object = [QSObject fileObjectWithPath:[QSRez pathWithLocatorInformation:[cmdDict objectForKey:@"directResource"]]];

// For cases where we really can't determine the object
if (!object) {
NSLog(@"Warning: no direct object for Command %@\nCommand Dictionary: %@", self, cmdDict);
}
return object;
}

- (QSObject *)iObject {
QSObject *object = iObject;
if (!object) {
object = [QSObject objectWithIdentifier:[[self commandDict] objectForKey:@"indirectID"]];
[self setIndirectObject:object];
}
if (!object) {
if (object) {
return object;
}

NSDictionary *cmdDict = [self commandDict];
NSString *indirectID = [cmdDict objectForKey:@"indirectID"];
if (indirectID) {
object = [QSObject objectWithIdentifier:indirectID];
if (!object) {
// For cases where the object doesn't exist
if (!object) {
// create an object by sniffing the string
object = [QSObject objectWithString:indirectID];
}
}
}

if (!object) {
object = [QSObject objectWithDictionary:[[self commandDict] objectForKey:@"indirectArchive"]];
[self setIndirectObject:object];
}
if (!object)
object = [QSObject fileObjectWithPath:[QSRez pathWithLocatorInformation:[[self commandDict] objectForKey:@"indirectResource"]]];
return object;

[self setIndirectObject:object];

if (!object) {
object = [QSObject fileObjectWithPath:[QSRez pathWithLocatorInformation:[cmdDict objectForKey:@"indirectResource"]]];
}

return object;
}

- (NSComparisonResult) compare:(id)compareObject {
Expand Down
6 changes: 5 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSObject.m
Expand Up @@ -629,6 +629,11 @@ - (NSString *)identifier {
return ident;
}

/* WARNING: If you are receiving EXC_BAD_ACCESS messages here, it is due to Quicksilver's catalog
containg multiple objects with the same identifier. Best efforts should be made to create objects with unique
identifiers. If not possible, then efforts should be made to check if an object already exists with a specific
identifier before creating a new one.
Note by p_j_r 17/07/2011 */
- (void)setIdentifier:(NSString *)newIdentifier {
if (identifier != nil) {
@synchronized(objectDictionary) {
Expand All @@ -641,7 +646,6 @@ - (void)setIdentifier:(NSString *)newIdentifier {
if (newIdentifier != nil) {
flags.noIdentifier = NO;
@synchronized(objectDictionary) {
#warning got a EXC_BAD_ACCESS here Patrick Robertson 17/05/11
[objectDictionary setObject:self forKey:newIdentifier];
}
[meta setObject:newIdentifier forKey:kQSObjectObjectID];
Expand Down
12 changes: 10 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m
Expand Up @@ -723,9 +723,17 @@ + (NSMutableArray *)fileObjectsWithURLArray:(NSArray *)pathArray {
return fileObjectArray;
}

- (id)initWithArray:(NSArray *)paths { //**this function could create dups
- (id)initWithArray:(NSArray *)paths {
NSString *thisIdentifier = identifierForPaths(paths);

// return an already-created object if it exists
QSObject *existingObject = [QSObject objectWithIdentifier:thisIdentifier];
if (existingObject) {
return existingObject;
}

// if no previous object has been created, then create a new one
if (self = [self init]) {
NSString *thisIdentifier = identifierForPaths(paths);
if ([paths count] == 1) {
NSString *path = [paths lastObject];
[[self dataDictionary] setObject:path forKey:QSFilePathType];
Expand Down
5 changes: 4 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSObject_StringHandling.m
Expand Up @@ -98,10 +98,13 @@ - (void)sniffString {
}
}
if ([[NSFileManager defaultManager] filesExistAtPaths:files]) {
if (line >= 0)
if (line >= 0) {
[self setObject:[NSDictionary dictionaryWithObjectsAndKeys:[files lastObject] , @"path", [NSNumber numberWithInt:line] , @"line", nil] forType:@"QSLineReferenceType"];
}
[self setObject:files forType:QSFilePathType];
[self setPrimaryType:QSFilePathType];
// set an appropriate name based on the files
[self getNameFromFiles];
}
return;
}
Expand Down
2 changes: 2 additions & 0 deletions Quicksilver/Code-QuickStepCore/QSTrigger.m
Expand Up @@ -169,6 +169,8 @@ - (BOOL)isPreset {
return [[info objectForKey:kItemID] hasPrefix:@"QS"];
}

// if the command has a preset (e.g. a built in command/trigger for a plugin: performs a single action),
// it is a single string as opposed to an NSDict with an 'action' and 'direct object' (or 'indirect object')
- (BOOL)usesPresetCommand {
return ([[info objectForKey:@"command"] isKindOfClass:[NSString class]]);
}
Expand Down

0 comments on commit 0ed2054

Please sign in to comment.