diff options
author | Max <post@wickenrode.com> | 2015-05-10 01:24:34 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-05-10 01:48:44 +0200 |
commit | 0f11cb74639d17a2fe512ed81d67ccf33601b605 (patch) | |
tree | a5a8a24ce11070e3ded9ad0a31422de79a486442 /Source | |
parent | 7dbcadc2c0523dc3c3bcc0a8cd7ceea9f44fc655 (diff) | |
download | sequelpro-0f11cb74639d17a2fe512ed81d67ccf33601b605.tar.gz sequelpro-0f11cb74639d17a2fe512ed81d67ccf33601b605.tar.bz2 sequelpro-0f11cb74639d17a2fe512ed81d67ccf33601b605.zip |
* Fix an exception that would occur if a user tried to export favorites when no favorites are selected
* Select "Quick Connect" after deleting a favorite
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionController.m | 20 | ||||
-rw-r--r-- | Source/SPConnectionControllerDelegate.m | 2 |
2 files changed, 14 insertions, 8 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 7cde1e4e..25049d44 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -1039,10 +1039,17 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (IBAction)exportFavorites:(id)sender { - NSSavePanel *savePanel = [NSSavePanel savePanel]; + // additional empty selection check + if(![[self selectedFavoriteNodes] count]) return; - NSString *fileName = [[self selectedFavoriteNodes] count] > 1 ? SPExportFavoritesFilename : [[[self selectedFavorite] objectForKey:SPFavoriteNameKey] stringByAppendingPathExtension:@"plist"]; + NSSavePanel *savePanel = [NSSavePanel savePanel]; + // suggest the name of the favorite or a default name for multiple selection + NSString *fileName = ([[self selectedFavoriteNodes] count] == 1)? [[[self selectedFavorite] objectForKey:SPFavoriteNameKey] stringByAppendingPathExtension:@"plist"] : nil; + // This if() is so we can also catch nil due to favorite corruption (NSSavePanel will @throw if nil is passed in) + if(!fileName) + fileName = SPExportFavoritesFilename; + [savePanel setAccessoryView:exportPanelAccessoryView]; [savePanel setNameFieldStringValue:fileName]; @@ -1652,7 +1659,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, { [favoritesOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[favoritesOutlineView rowForItem:node]] byExtendingSelection:NO]; [self _scrollToSelectedNode]; - } +} /** * Scroll to the currently selected node. @@ -1663,7 +1670,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if ([favoritesOutlineView selectedRow] == -1) return; [favoritesOutlineView scrollRowToVisible:[favoritesOutlineView selectedRow]]; - } +} /** * Removes the supplied tree node. @@ -1678,9 +1685,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self _reloadFavoritesViewData]; - // Clear the selection and update the interface to match - [favoritesOutlineView selectRowIndexes:nil byExtendingSelection:NO]; - [self updateFavoriteSelection:self]; + // Select Quick Connect item to prevent empty selection + [self _selectNode:quickConnectItem]; [connectionResizeContainer setHidden:NO]; [connectionInstructionsTextField setStringValue:NSLocalizedString(@"Enter connection details below, or choose a favorite", @"enter connection details label")]; diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index f0813292..f2a57e53 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -656,7 +656,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; // Favorites export if (action == @selector(exportFavorites:)) { - if ([[favoritesRoot allChildLeafs] count] == 0) { + if ([[favoritesRoot allChildLeafs] count] == 0 || selectedRows == 0) { return NO; } else if (selectedRows == 1) { |