Permalink
Browse files

* Fix a case of "background thread updating UI" (may affect some cras…

…hes when importing CSVs)
  • Loading branch information...
dmoagx committed Apr 22, 2017
1 parent dfab0cd commit bed1cff292d5997b1b5a822be48ed92d31db9590
Showing with 35 additions and 30 deletions.
  1. +1 −1 Source/SPAppController.m
  2. +22 −21 Source/SPDataImport.m
  3. +9 −7 Source/SPTableContent.m
  4. +3 −1 Source/SPTablesList.m
View
@@ -770,7 +770,7 @@ - (void)handleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEvent
}
else {
NSBeep();
NSLog(@"Error in sequelpro URL scheme");
NSLog(@"Error in sequelpro URL scheme for URL <%@>",url);
}
}
View
@@ -1213,29 +1213,30 @@ - (void)importCSVFile:(NSString *)filename
document:tableDocumentInstance
notificationName:@"Import Finished"];
SPMainQSync(^{
if(importIntoNewTable) {
if(importIntoNewTable) {
// Select the new table
// Update current database tables
[[tablesListInstance onMainThread] updateTables:self];
// Re-query the structure of all databases in the background
[[tableDocumentInstance databaseStructureRetrieval] queryDbStructureInBackgroundWithUserInfo:@{@"forceUpdate" : @YES}];
// Select the new table
[tablesListInstance selectItemWithName:selectedTableTarget];
} else {
// If import was done into a new table or the table selected for import is also selected in the content view,
// update the content view - on the main thread to avoid crashes.
if ([tablesListInstance tableName] && [selectedTableTarget isEqualToString:[tablesListInstance tableName]]) {
[tableDocumentInstance setContentRequiresReload:YES];
// Select the new table
// Update current database tables
[tablesListInstance updateTables:self];
// Re-query the structure of all databases in the background
[[tableDocumentInstance databaseStructureRetrieval] queryDbStructureInBackgroundWithUserInfo:@{@"forceUpdate" : @YES}];
// Select the new table
[tablesListInstance selectItemWithName:selectedTableTarget];
} else {
// If import was done into a new table or the table selected for import is also selected in the content view,
// update the content view - on the main thread to avoid crashes.
if ([tablesListInstance tableName] && [selectedTableTarget isEqualToString:[tablesListInstance tableName]]) {
[tableDocumentInstance setContentRequiresReload:YES];
}
}
}
});
}
View
@@ -2541,13 +2541,15 @@ - (void)clickLinkArrowTask:(SPTextAndLinkCell *)theArrowCell
@"filterValue": targetFilterValue,
@"filterComparison": SPBoxNil(filterComparison)
};
[self setFiltersToRestore:filterSettings];
// Attempt to switch to the target table
if (![tablesListInstance selectItemWithName:[refDictionary objectForKey:@"table"]]) {
NSBeep();
[self setFiltersToRestore:nil];
}
SPMainQSync(^{
[self setFiltersToRestore:filterSettings];
// Attempt to switch to the target table
if (![tablesListInstance selectItemWithName:[refDictionary objectForKey:@"table"]]) {
NSBeep();
[self setFiltersToRestore:nil];
}
});
}
#ifndef SP_CODA
View
@@ -1370,6 +1370,8 @@ - (BOOL)hasNonTableObjects
/**
* Select an item using the provided name; returns YES if the
* supplied name could be selected, or NO if not.
*
* MUST BE CALLED ON THE UI THREAD!
*/
- (BOOL)selectItemWithName:(NSString *)theName
{
@@ -1418,7 +1420,7 @@ - (BOOL)selectItemWithName:(NSString *)theName
}
}
[[tablesListView onMainThread] scrollRowToVisible:[tablesListView selectedRow]];
[tablesListView scrollRowToVisible:[tablesListView selectedRow]];
#endif
return YES;

0 comments on commit bed1cff

Please sign in to comment.