aboutsummaryrefslogtreecommitdiffstats
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
parentfa8ef20485323e394af10cd3a9937b634d47b436 (diff)
downloadsequelpro-71524d822dd449c131f6e09b2a0be0c3c0101eb1.tar.gz
sequelpro-71524d822dd449c131f6e09b2a0be0c3c0101eb1.tar.bz2
sequelpro-71524d822dd449c131f6e09b2a0be0c3c0101eb1.zip
Fix crash when deleting a group node.
-rw-r--r--Source/SPConnectionController.m58
-rw-r--r--Source/SPFavoritesController.m2
2 files changed, 32 insertions, 28 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];
diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m
index 2d711c4b..920cec6b 100644
--- a/Source/SPFavoritesController.m
+++ b/Source/SPFavoritesController.m
@@ -174,7 +174,7 @@ static SPFavoritesController *sharedFavoritesController = nil;
[favoritesTree removeObjectFromChildren:node];
// Save data to disk
- [self saveFavorites];
+ [self reloadFavoritesWithSave:YES];
}
#pragma mark -