Skip to content

Commit bfc53dc

Browse files
committed
Fix a case of "background thread updating UI"
1 parent bede490 commit bfc53dc

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

Source/SPDatabaseDocument.m

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6303,22 +6303,24 @@ - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails
63036303

63046304
#ifndef SP_CODA /* update selected table in SPTablesList */
63056305

6306-
BOOL focusOnFilter = YES;
6307-
if (targetItemName) focusOnFilter = NO;
6308-
6309-
// If a the table has changed, update the selection
6310-
if (![targetItemName isEqualToString:[self table]] && targetItemName) {
6311-
focusOnFilter = ![tablesListInstance selectItemWithName:targetItemName];
6312-
}
6313-
6314-
// Ensure the window focus is on the table list or the filter as appropriate
6315-
[[tablesListInstance onMainThread] setTableListSelectability:YES];
6316-
if (focusOnFilter) {
6317-
[[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
6318-
} else {
6319-
[[tablesListInstance onMainThread] makeTableListHaveFocus];
6320-
}
6321-
[[tablesListInstance onMainThread] setTableListSelectability:NO];
6306+
SPMainQSync(^{
6307+
BOOL focusOnFilter = YES;
6308+
if (targetItemName) focusOnFilter = NO;
6309+
6310+
// If a the table has changed, update the selection
6311+
if (![targetItemName isEqualToString:[self table]] && targetItemName) {
6312+
focusOnFilter = ![tablesListInstance selectItemWithName:targetItemName];
6313+
}
6314+
6315+
// Ensure the window focus is on the table list or the filter as appropriate
6316+
[tablesListInstance setTableListSelectability:YES];
6317+
if (focusOnFilter) {
6318+
[tablesListInstance makeTableListFilterHaveFocus];
6319+
} else {
6320+
[tablesListInstance makeTableListHaveFocus];
6321+
}
6322+
[tablesListInstance setTableListSelectability:NO];
6323+
});
63226324

63236325
#endif
63246326
[self endTask];

0 commit comments

Comments
 (0)