From d1321478bd7334437a853bca3c5202000de1a2d5 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 12 Jul 2016 23:13:03 +0200 Subject: Fix a potential memory management / multi threading issue (#2513) --- Source/SPTablesList.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 338ecd7e..77817040 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -59,6 +59,7 @@ #import "SPSplitView.h" #endif #import "SPThreadAdditions.h" +#import "SPFunctions.h" #ifdef SP_CODA #import "SQLSidebarViewController.h" @@ -208,8 +209,12 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [[tablesListView onMainThread] deselectAll:self]; tableListIsSelectable = previousTableListIsSelectable; #endif - [tables removeAllObjects]; - [tableTypes removeAllObjects]; + SPMainQSync(^{ + //this has to be executed en-block on the main queue, otherwise the table view might have a chance to access released memory before we tell it to throw away everything. + [tables removeAllObjects]; + [tableTypes removeAllObjects]; + [tablesListView reloadData]; + }); if ([tableDocumentInstance database]) { -- cgit v1.2.3