Skip to content

Commit d132147

Browse files
committed
Fix a potential memory management / multi threading issue (#2513)
1 parent 7f8e159 commit d132147

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Source/SPTablesList.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#import "SPSplitView.h"
6060
#endif
6161
#import "SPThreadAdditions.h"
62+
#import "SPFunctions.h"
6263

6364
#ifdef SP_CODA
6465
#import "SQLSidebarViewController.h"
@@ -208,8 +209,12 @@ - (IBAction)updateTables:(nullable id)sender
208209
[[tablesListView onMainThread] deselectAll:self];
209210
tableListIsSelectable = previousTableListIsSelectable;
210211
#endif
211-
[tables removeAllObjects];
212-
[tableTypes removeAllObjects];
212+
SPMainQSync(^{
213+
//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.
214+
[tables removeAllObjects];
215+
[tableTypes removeAllObjects];
216+
[tablesListView reloadData];
217+
});
213218

214219
if ([tableDocumentInstance database]) {
215220

0 commit comments

Comments
 (0)