Skip to content

Commit c5525ba

Browse files
committed
Fix a concurrent modification exception that could occur when duplicating a database
1 parent feff69b commit c5525ba

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Source/SPDatabaseDocument.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6145,7 +6145,7 @@ - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails
61456145

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

6161-
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]);
6161+
SPOnewayAlertSheet(
6162+
NSLocalizedString(@"Error", @"error"),
6163+
nil,
6164+
parentWindow,
6165+
[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]
6166+
);
61626167
}
61636168

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

62086213
// Ensure the window focus is on the table list or the filter as appropriate
6209-
[[tablesListInstance onMainThread] setTableListSelectability:YES];
6214+
[[tablesListInstance onMainThread] setTableListSelectability:YES];
62106215
if (focusOnFilter) {
62116216
[[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
62126217
} else {
62136218
[[tablesListInstance onMainThread] makeTableListHaveFocus];
62146219
}
6215-
[[tablesListInstance onMainThread] setTableListSelectability:NO];
6220+
[[tablesListInstance onMainThread] setTableListSelectability:NO];
62166221

62176222
#endif
62186223
[self endTask];

0 commit comments

Comments
 (0)