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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

An assortment of 4020 bugfixes #2383

Merged
merged 8 commits into from
Aug 1, 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
13 changes: 12 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,21 @@ - (NSArray *)actionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject

@implementation QSBasicObject (FileHandling)

- (NSString *)singleFilePath {return [self objectForType:QSFilePathType];}
- (NSString *)singleFilePath {
NSString *path = [self objectForType:QSFilePathType];
if (![path isKindOfClass:[NSString class]]) {
NSLog(@"unexpected object for file path: %@, object: %@", path, self);
return nil;
}
return path;
}

- (NSString *)validSingleFilePath {
NSString *path = [self objectForType:QSFilePathType];
if (![path isKindOfClass:[NSString class]]) {
NSLog(@"unexpected object for file path: %@, object: %@", path, self);
return nil;
}
if (path && [[NSFileManager defaultManager] fileExistsAtPath:path])
return path;
return nil;
Expand Down
7 changes: 6 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSObject_Pasteboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ - (void)addContentsOfPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)type
} else {
NSLog(@"bad data for %@", thisType);
}
[typeArray addObject:[thisType decodedPasteboardType]];
NSString *decodedType = [thisType decodedPasteboardType];
if (!decodedType) {
NSLog(@"Failed to decode pasteboard type: %@", thisType);
continue;
}
[typeArray addObject:decodedType];
}
}
}
Expand Down
95 changes: 60 additions & 35 deletions Quicksilver/Code-QuickStepCore/QSPlugInManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ - (QSPlugIn *)plugInWithBundle:(NSBundle *)bundle {
[plugin setBundle:bundle];
} else {
plugin = [QSPlugIn plugInWithBundle:bundle];
if (!plugin) {
NSLog(@"Failed to initialize plugin for bundle %@", bundle);
return nil;
}
[knownPlugIns setObject:plugin forKey:[bundle bundleIdentifier]];
}
return plugin;
Expand Down Expand Up @@ -279,7 +283,8 @@ - (void)loadNewWebData:(NSData *)data {
NSString *errorString;
self.downloadTask.status = NSLocalizedString(@"Updating plugin info", @"");
NSError *error = nil;
NSDictionary *prop = [NSPropertyListSerialization propertyListWithData:data
NSDictionary *prop = nil;
if (data) prop = [NSPropertyListSerialization propertyListWithData:data
options:NSPropertyListImmutable
format:NULL
error:&error];
Expand Down Expand Up @@ -382,50 +387,70 @@ - (void)checkForUnmetDependencies {
if (VERBOSE) NSLog(@"Unmet Dependencies: %@", dependingPlugIns);
#endif
NSMutableArray *array = [NSMutableArray array];
NSMutableSet *dependingNames = [NSMutableSet set];
foreachkey(ident, plugins, dependingPlugIns) {
if ([(NSArray *)plugins count]) {
// ignore dependencies for plug-ins that won't load under the current architecture
BOOL loadDependencies = NO;
for (QSPlugIn *plugin in plugins) {
if ([plugin isSupported]) {
// if any one of the depending plug-ins is supported, get the prerequisite
loadDependencies = YES;
break;
}
}
if (loadDependencies) {
NSArray *dependencies = [[plugins lastObject] dependencies];
NSDictionary *supportingPlugIn = [dependencies objectWithValue:ident forKey:@"id"];
if (![[localPlugIns allKeys] containsObject:[supportingPlugIn objectForKey:@"id"]]) {
// supporting plug-in is not yet installed
[array addObject:supportingPlugIn];
[dependingNames addObjectsFromArray:[plugins valueForKey:@"name"]];
}
NSMutableSet *dependingNamesSet = [NSMutableSet set];
for (NSString *ident in dependingPlugIns) {
NSArray *plugins = dependingPlugIns[ident];

if (![plugins count]) continue;

// ignore dependencies for plug-ins that won't load under the current architecture
BOOL loadDependencies = NO;
for (QSPlugIn *plugin in plugins) {
if ([plugin isSupported]) {
// if any one of the depending plug-ins is supported, get the prerequisite
loadDependencies = YES;
break;
}
}
if (!loadDependencies) continue;

QSPlugIn *plugin = plugins.lastObject;
NSArray *dependencies = [plugin dependencies];
NSDictionary *supportingPlugIn = [dependencies objectWithValue:ident forKey:@"id"];
if (supportingPlugIn == nil) {
NSLog(@"invalid dependency for %@ in plugin %@", ident, plugin.identifier);
continue;
}

if (![[localPlugIns allKeys] containsObject:[supportingPlugIn objectForKey:@"id"]]) {
// supporting plug-in is not yet installed
[array addObject:supportingPlugIn];
[dependingNamesSet addObjectsFromArray:[plugins valueForKey:@"name"]];
}
}

// NSLog(@"installing! %@", array);
if (![array count]) return;

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QSAlwaysInstallPrerequisites"]) {
[self installPlugInsForIdentifiers:[array valueForKey:@"id"] version:nil];

} else {
//[NSApp activateIgnoringOtherApps:YES];
NSInteger selection = NSRunInformationalAlertPanel([NSString stringWithFormat:@"Plugin Requirements", nil] ,
@"Using [%@] requires installation of [%@] .", @"Install", @"Disable", @"Always Install Requirements",
[[dependingNames allObjects] componentsJoinedByString:@", "] ,
[[array valueForKey:@"name"] componentsJoinedByString:@", "]);
if (selection == 1) {
[self installPlugInsForIdentifiers:[array valueForKey:@"id"] version:nil];
} else if (selection == -1) { //Go to web site
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"QSAlwaysInstallPrerequisites"];
[self installPlugInsForIdentifiers:[array valueForKey:@"id"] version:nil];

}
return;
}

NSString *dependingNames = [[dependingNamesSet allObjects] componentsJoinedByString:@", "];
NSString *unmetPluginNames = [[array valueForKey:@"name"] componentsJoinedByString:@", "];

NSString *message = [NSString stringWithFormat:NSLocalizedString(@"There are missing dependencies: %@\n\nThe following plugins will not work until those plugins are installed: %@", @"Missing dependencies alert - message (depending plugin names, unmet plugin names)"), dependingNames, unmetPluginNames];
NSArray *buttons = @[
NSLocalizedString(@"Install", @"Missing dependencies alert - button 1"),
NSLocalizedString(@"Disable", @"Missing dependencies alert - button 2"),
NSLocalizedString(@"Always Install Requirements", @"Missing dependencies alert - button 3")
];

[[QSAlertManager defaultManager] beginAlertWithTitle:NSLocalizedString(@"Plugin requirements", @"Missing dependencies alert - title")
message:message
buttons:buttons
style:NSAlertStyleWarning
onWindow:nil
completionHandler:^(QSAlertResponse response) {
if (response == QSAlertResponseCancel) return;

if (response == QSAlertResponseThird) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"QSAlwaysInstallPrerequisites"];
}

[self installPlugInsForIdentifiers:[array valueForKey:@"id"] version:nil];
}];
}

- (void)checkForObsoletes:(QSPlugIn *)plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ - (void)resetAdjustTimer {

- (void)adjustWindow:(id)sender {
QSAction *action = (QSAction *)[aSelector objectValue];
if (![action isKindOfClass:[QSAction class]]) {
NSLog(@"Non-action in aSelector, resetting: %@", action);
[self clearObjectView:aSelector];
return;
}
NSInteger argumentCount = [action argumentCount];

// NSLog(@"adjust x%d", argumentCount);
Expand Down