Skip to content

Commit 82c43d2

Browse files
author
Joe Page
committed
- fix the long delay/spinner when selecting tables:
> [NSTableView removeColumns] method was taking a LONG time to return - clearing the data first and then removing the columns made a big difference. > also, reload table view (2nd time) after allowing main thread to return. user will see a faster table selection & an empty table view - then data will populate
1 parent 856fe0f commit 82c43d2

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

CoreDataUtil/CoreData/MFLCoreDataIntrospection.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ - (NSArray*) getDataAtRow: (NSUInteger) row {
417417
return (self.entityData)[row];
418418
}
419419
else {
420-
NSLog(@"getDataAtRow: bad row:%d", (int)row);
420+
NSLog(@"getDataAtRow: bad row:%d, #rows:%d", (int)row, (int)[self entityDataCount]);
421421
return nil;
422422
}
423423
}
@@ -434,7 +434,6 @@ - (void)setCurrentHistoryIndex:(NSInteger)currentIndex
434434

435435
- (void)updateCoreDataHistory:(NSString *)name predicate:(NSPredicate *)predicate objectType:(MFLObjectType)type
436436
{
437-
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
438437
if (self.coreDataHistory == nil)
439438
{
440439
self.coreDataHistory = [[NSMutableArray alloc] initWithCapacity:CORE_DATA_HISTORY_MAX];
@@ -468,7 +467,6 @@ - (void)updateCoreDataHistory:(NSString *)name predicate:(NSPredicate *)predicat
468467
[self.coreDataHistory removeObjectAtIndex:currentHistoryIndex + 1];
469468
}
470469
}
471-
NSLog(@"updateCoreDataHistory: %@, %@ms", name, [MFLUtils duration:startTime]);
472470
}
473471

474472
@end

CoreDataUtil/MFLMainWindowController.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,9 @@ - (void)onEntitySelected {
250250
if ([self.dataSourceList selectedRow] >= 0)
251251
{
252252
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
253-
254-
[self removeColumns];
255253
[self.coreDataIntrospection clearEntityData];
256254
[self.entityContentTable reloadData];
255+
[self removeColumns];
257256

258257
self.sortType = Unsorted;
259258
OutlineViewNode *selectedNode = [self.dataSourceList itemAtRow:[self.dataSourceList selectedRow]];
@@ -286,7 +285,11 @@ - (void)onEntitySelected {
286285
predicate:[[self.coreDataIntrospection fetchRequest:selected] predicate]
287286
objectType:MFLObjectTypeFetchRequest];
288287
}
289-
[self.entityContentTable reloadData];
288+
289+
// allow main thread to return before calling reloadData again. user will see a faster table selection & an empty table view - then data will populate
290+
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
291+
[self.entityContentTable reloadData];
292+
}];
290293

291294
[self enableDisableHistorySegmentedControls];
292295
NSLog(@"Selected %@, selected=%d, section:%d, %@ms", selectedNode.title, (int)selected, (int)section, [MFLUtils duration:startTime]);

0 commit comments

Comments
 (0)