diff options
author | rowanbeentje <rowan@beent.je> | 2010-03-07 23:45:02 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-03-07 23:45:02 +0000 |
commit | 2938fe935e88af318090cbe463a338ce69d758ea (patch) | |
tree | 679dc28e6aa74facfdc658e5600b9530f228c18e /Source | |
parent | bd6f166e4e4a119ef439b31478c0f19959753074 (diff) | |
download | sequelpro-2938fe935e88af318090cbe463a338ce69d758ea.tar.gz sequelpro-2938fe935e88af318090cbe463a338ce69d758ea.tar.bz2 sequelpro-2938fe935e88af318090cbe463a338ce69d758ea.zip |
- Fix exception on duplication of table source rows that haven't been saved yet; this addresses http://log.sequelpro.com/view/23
- Clean up fix in r1859
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionController.m | 2 | ||||
-rw-r--r-- | Source/TableSource.m | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index b3096954..956312c1 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -504,7 +504,7 @@ [prefsController showWindow:self]; [prefsController displayFavoritePreferences:self]; - if ([favoritesTable selectedRow] != -1) [prefsController selectFavoriteAtIndex:([favoritesTable selectedRow] - 1)]; + if ([favoritesTable numberOfSelectedRows]) [prefsController selectFavoriteAtIndex:([favoritesTable selectedRow] - 1)]; } /** diff --git a/Source/TableSource.m b/Source/TableSource.m index 655dffc1..44a11321 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -325,16 +325,20 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab - (IBAction)copyField:(id)sender { NSMutableDictionary *tempRow; + NSUInteger rowToCopy; - if ( ![tableSourceView numberOfSelectedRows] ) { - [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:[tableSourceView numberOfRows]-1] byExtendingSelection:NO]; + // Store the row to duplicate, as saveRowOnDeselect and subsequent reloads may trigger a deselection + if ([tableSourceView numberOfSelectedRows]) { + rowToCopy = [tableSourceView selectedRow]; + } else { + rowToCopy = [tableSourceView numberOfRows]-1; } // Check whether a save of the current row is required. if ( ![self saveRowOnDeselect] ) return; //add copy of selected row and go in edit mode - tempRow = [NSMutableDictionary dictionaryWithDictionary:[tableFields objectAtIndex:[tableSourceView selectedRow]]]; + tempRow = [NSMutableDictionary dictionaryWithDictionary:[tableFields objectAtIndex:rowToCopy]]; [tempRow setObject:[[tempRow objectForKey:@"Field"] stringByAppendingString:@"Copy"] forKey:@"Field"]; [tempRow setObject:@"" forKey:@"Key"]; [tempRow setObject:@"None" forKey:@"Extra"]; |