Skip to content

Commit

Permalink
Fix a concurrent modification exception that could occur when duplica…
Browse files Browse the repository at this point in the history
…ting a database
  • Loading branch information
dmoagx committed Jul 20, 2015
1 parent feff69b commit c5525ba
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Source/SPDatabaseDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -6145,7 +6145,7 @@ - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails

// Attempt to select the specified database, and abort on failure
#ifndef SP_CODA /* patch */
if ([chooseDatabaseButton indexOfItemWithTitle:targetDatabaseName] == NSNotFound || ![mySQLConnection selectDatabase:targetDatabaseName])
if ([[chooseDatabaseButton onMainThread] indexOfItemWithTitle:targetDatabaseName] == NSNotFound || ![mySQLConnection selectDatabase:targetDatabaseName])
#else
if ( ![mySQLConnection selectDatabase:targetDatabaseName] )
#endif
Expand All @@ -6158,7 +6158,12 @@ - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails
// Update the database list
[[self onMainThread] setDatabases:self];

SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, parentWindow, self, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Unable to select database %@.\nPlease check you have the necessary privileges to view the database, and that the database still exists.", @"message of panel when connection to db failed after selecting from popupbutton"), targetDatabaseName]);
SPOnewayAlertSheet(
NSLocalizedString(@"Error", @"error"),
nil,
parentWindow,
[NSString stringWithFormat:NSLocalizedString(@"Unable to select database %@.\nPlease check you have the necessary privileges to view the database, and that the database still exists.", @"message of panel when connection to db failed after selecting from popupbutton"), targetDatabaseName]
);
}

[taskPool drain];
Expand Down Expand Up @@ -6203,16 +6208,16 @@ - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails
// If a the table has changed, update the selection
if (![targetItemName isEqualToString:[self table]] && targetItemName) {
focusOnFilter = ![tablesListInstance selectItemWithName:targetItemName];
}
}

// Ensure the window focus is on the table list or the filter as appropriate
[[tablesListInstance onMainThread] setTableListSelectability:YES];
[[tablesListInstance onMainThread] setTableListSelectability:YES];
if (focusOnFilter) {
[[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
} else {
[[tablesListInstance onMainThread] makeTableListHaveFocus];
}
[[tablesListInstance onMainThread] setTableListSelectability:NO];
[[tablesListInstance onMainThread] setTableListSelectability:NO];

#endif
[self endTask];
Expand Down

0 comments on commit c5525ba

Please sign in to comment.