aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2013-02-19 01:09:30 +0000
committerrowanbeentje <rowan@beent.je>2013-02-19 01:09:30 +0000
commit36fa01d0c98481af4b6a17061ac94c0a5a0186fe (patch)
treeef00c32dec151845f89b4d682847b71b7b393082 /Source
parentf7f5013b74e890c743482a3f6bb5dd36690a36da (diff)
downloadsequelpro-36fa01d0c98481af4b6a17061ac94c0a5a0186fe.tar.gz
sequelpro-36fa01d0c98481af4b6a17061ac94c0a5a0186fe.tar.bz2
sequelpro-36fa01d0c98481af4b6a17061ac94c0a5a0186fe.zip
- Fix crashes when importing favorites on the connection view, addressing Issue #1556
- Select and scroll to newly created favorites after import
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConnectionControllerDelegate.m17
-rw-r--r--Source/SPFavoritesImporter.m4
2 files changed, 16 insertions, 5 deletions
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m
index a6001309..ec1c65f1 100644
--- a/Source/SPConnectionControllerDelegate.m
+++ b/Source/SPConnectionControllerDelegate.m
@@ -57,6 +57,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf";
- (void)_sortFavorites;
- (void)_favoriteTypeDidChange;
- (void)_reloadFavoritesViewData;
+- (void)_scrollToSelectedNode;
- (NSString *)_stripInvalidCharactersFromString:(NSString *)subject;
@@ -665,17 +666,29 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf";
*/
- (void)favoritesImportData:(NSArray *)data
{
+ SPTreeNode *newNode;
+ NSMutableArray *importedNodes = [NSMutableArray array];
+ NSMutableIndexSet *importedIndexSet = [NSMutableIndexSet indexSet];
+
// Add each of the imported favorites to the root node
for (NSMutableDictionary *favorite in data)
{
- [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:nil];
+ newNode = [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:nil];
+ [importedNodes addObject:newNode];
}
if (currentSortItem > SPFavoritesSortUnsorted) {
[self _sortFavorites];
-}
+ }
[self _reloadFavoritesViewData];
+
+ // Select the new nodes and scroll into view
+ for (SPTreeNode *eachNode in importedNodes) {
+ [importedIndexSet addIndex:[favoritesOutlineView rowForItem:eachNode]];
+ }
+ [favoritesOutlineView selectRowIndexes:importedIndexSet byExtendingSelection:NO];
+ [self _scrollToSelectedNode];
}
/**
diff --git a/Source/SPFavoritesImporter.m b/Source/SPFavoritesImporter.m
index f33e1705..bb027104 100644
--- a/Source/SPFavoritesImporter.m
+++ b/Source/SPFavoritesImporter.m
@@ -73,12 +73,10 @@
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:[self importPath]]) {
- importData = [[NSDictionary alloc] initWithContentsOfFile:[self importPath]];
+ importData = [[[NSDictionary alloc] initWithContentsOfFile:[self importPath]] autorelease];
NSArray *favorites = [importData valueForKey:SPFavoritesDataRootKey];
- [importData release];
-
if (favorites) {
[self _informDelegateOfImportDataAvailable:favorites];
}