aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-12-06 22:18:39 +0000
committerstuconnolly <stuart02@gmail.com>2010-12-06 22:18:39 +0000
commit71524d822dd449c131f6e09b2a0be0c3c0101eb1 (patch)
tree76e4c4ad9e357954e407fd9df79adb2ade5fb065 /Source/SPConnectionController.m
parentfa8ef20485323e394af10cd3a9937b634d47b436 (diff)
downloadsequelpro-71524d822dd449c131f6e09b2a0be0c3c0101eb1.tar.gz
sequelpro-71524d822dd449c131f6e09b2a0be0c3c0101eb1.tar.bz2
sequelpro-71524d822dd449c131f6e09b2a0be0c3c0101eb1.zip
Fix crash when deleting a group node.
Diffstat (limited to 'Source/SPConnectionController.m')
-rw-r--r--Source/SPConnectionController.m58
1 files changed, 31 insertions, 27 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 979f59bb..f7a09471 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -1025,36 +1025,40 @@ static const NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
if ([contextInfo isEqualToString:SPRemoveNode]) {
if (returnCode == NSAlertDefaultReturn) {
- NSDictionary *favorite = [self selectedFavorite];
+ SPTreeNode *node = [self selectedFavoriteNode];
- // Get selected favorite's details
- NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey];
- NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey];
- NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey];
- NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey];
- NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey];
- NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey];
- NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey];
-
- NSInteger favoriteType = [[favorite objectForKey:SPFavoriteTypeKey] integerValue];
-
- // Remove passwords from the Keychain
- [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID]
- account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]];
- [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID]
- account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]];
-
- // Reset last used favorite
- if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) {
- [prefs setInteger:0 forKey:SPLastFavoriteID];
- }
-
- // Reset default favorite
- if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) {
- [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite];
+ if (![node isGroup]) {
+ NSDictionary *favorite = [[node representedObject] nodeFavorite];
+
+ // Get selected favorite's details
+ NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey];
+ NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey];
+ NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey];
+ NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey];
+ NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey];
+ NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey];
+ NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey];
+
+ NSInteger favoriteType = [[favorite objectForKey:SPFavoriteTypeKey] integerValue];
+
+ // Remove passwords from the Keychain
+ [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID]
+ account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]];
+ [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID]
+ account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]];
+
+ // Reset last used favorite
+ if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) {
+ [prefs setInteger:0 forKey:SPLastFavoriteID];
+ }
+
+ // Reset default favorite
+ if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) {
+ [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite];
+ }
}
- [favoritesController removeFavoriteNode:[self selectedFavoriteNode]];
+ [favoritesController removeFavoriteNode:node];
[self _reloadFavoritesViewData];