Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a case of "background thread updating UI"
  • Loading branch information
dmoagx committed Jun 26, 2016
1 parent bede490 commit bfc53dc
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions Source/SPDatabaseDocument.m
Expand Up @@ -6303,22 +6303,24 @@ - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails

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

BOOL focusOnFilter = YES;
if (targetItemName) focusOnFilter = NO;

// 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];
if (focusOnFilter) {
[[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
} else {
[[tablesListInstance onMainThread] makeTableListHaveFocus];
}
[[tablesListInstance onMainThread] setTableListSelectability:NO];
SPMainQSync(^{
BOOL focusOnFilter = YES;
if (targetItemName) focusOnFilter = NO;

// 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 setTableListSelectability:YES];
if (focusOnFilter) {
[tablesListInstance makeTableListFilterHaveFocus];
} else {
[tablesListInstance makeTableListHaveFocus];
}
[tablesListInstance setTableListSelectability:NO];
});

#endif
[self endTask];
Expand Down

0 comments on commit bfc53dc

Please sign in to comment.