diff --git a/app/controllers/PassengerPref.m b/app/controllers/PassengerPref.m index 666582c..b5d0747 100644 --- a/app/controllers/PassengerPref.m +++ b/app/controllers/PassengerPref.m @@ -44,7 +44,9 @@ - (void) setupAuthorizationView { - (void) setupApplicationView { [self loadApplications]; - [applicationsController setSelectedObjects:[NSArray arrayWithObjects:[applications objectAtIndex:0], nil]]; + if ([applications count] > 0) { + [applicationsController setSelectedObjects:[NSArray arrayWithObjects:[applications objectAtIndex:0], nil]]; + } [applicationsTableView registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]]; [applicationsTableView setDraggingSourceOperationMask:NSDragOperationGeneric forLocal:NO]; } @@ -100,7 +102,7 @@ - (BOOL) tableView:(NSTableView *)aTableView acceptDrop:(id)info row:(NSInteger) [droppedApplications addObject:application]; } [applicationsController addObjects:droppedApplications]; - [self checkForDirtyApplications]; + [self apply:self]; return YES; } @@ -147,6 +149,7 @@ - (IBAction) remove:(id)sender { [[CLI sharedInstance] delete:application]; } [applicationsController removeObject:application]; + [self checkForDirtyApplications]; } - (IBAction) browse:(id)sender { @@ -189,6 +192,7 @@ - (IBAction) apply:(id)sender { } else { NSLog(@"Unable to apply because authorization failed."); } + [self checkForDirtyApplications]; } - (IBAction) revert:(id)sender { Application *application; @@ -239,7 +243,11 @@ - (void) reloadApplications { } - (Application *) selectedApplication { - return [[applicationsController selectedObjects] objectAtIndex:0]; + if (applications && ([applications count] > 0)) { + return [[applicationsController selectedObjects] objectAtIndex:0]; + } else { + return nil; + } } - (NSString *) pathForDirectoryBrowser { diff --git a/app/utils/CLI.m b/app/utils/CLI.m index 2a5916e..6e3fbb2 100644 --- a/app/utils/CLI.m +++ b/app/utils/CLI.m @@ -30,10 +30,12 @@ - (NSMutableArray *)listApplications { result = [self execute:[NSArray arrayWithObjects:@"list", @"-m", nil] elevated:NO]; applications = [NSMutableArray arrayWithCapacity:[result count]]; - for (attributes in result) { - application = [[Application alloc] initWithAttributes:attributes]; - [application setDelegate:appDelegate]; - [applications addObject:application]; + if ([result count] > 0) { + for (attributes in result) { + application = [[Application alloc] initWithAttributes:attributes]; + [application setDelegate:appDelegate]; + [applications addObject:application]; + } } return applications; diff --git a/doc/TODO b/doc/TODO index 126e6ed..85d9a0c 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,4 +1,3 @@ -- Immediately apply the configuration when a new application is added. In most cases the default configuration is exactly what you want. - Prevent duplicate folders. When the user tries to add a duplicate folder, select the configuration for the application that uses this folder in the source list. - Do not accept characters in the Address and Aliases fields that can't be used for the domain name (including whitespace in the address field). - Check for duplicate addresses and aliases after Apply has been clicked. Show a sheet with the following alert: