aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2016-07-12 23:13:03 +0200
committerMax <post@wickenrode.com>2016-07-12 23:13:03 +0200
commitd1321478bd7334437a853bca3c5202000de1a2d5 (patch)
tree8b5f970ca77e3f7a0a03ae77ff60529b296a3331 /Source
parent7f8e159900b8fb365aab72b146a05ffc3699f4dd (diff)
downloadsequelpro-d1321478bd7334437a853bca3c5202000de1a2d5.tar.gz
sequelpro-d1321478bd7334437a853bca3c5202000de1a2d5.tar.bz2
sequelpro-d1321478bd7334437a853bca3c5202000de1a2d5.zip
Fix a potential memory management / multi threading issue (#2513)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTablesList.m9
1 files changed, 7 insertions, 2 deletions
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]) {