aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-08-02 21:29:59 +0200
committerMax <post@wickenrode.com>2015-08-02 21:29:59 +0200
commit9728737f9b695147e3957f401cc254f49afe7c6d (patch)
treec2767f3f3d53db5ad734085c4200e79ba2ba9dc5 /Source
parentb158c4134dde0363f1f225f97f5843dc1484dd13 (diff)
downloadsequelpro-9728737f9b695147e3957f401cc254f49afe7c6d.tar.gz
sequelpro-9728737f9b695147e3957f401cc254f49afe7c6d.tar.bz2
sequelpro-9728737f9b695147e3957f401cc254f49afe7c6d.zip
Fix a crash that could occur when cancelling an export (fixes #2192)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPExportController.m19
1 files changed, 17 insertions, 2 deletions
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index b0c543cf..97840171 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -72,6 +72,9 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
- (void)_resizeWindowForCustomFilenameViewByHeightDelta:(NSInteger)delta;
- (void)_resizeWindowForAdvancedOptionsViewByHeightDelta:(NSInteger)delta;
+- (void)_waitUntilQueueIsEmpty:(id)sender;
+- (void)_queueIsEmpty:(id)sender;
+
@end
@implementation SPExportController
@@ -364,8 +367,20 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
[sender setEnabled:NO];
// Cancel all of the currently running operations
- [operationQueue cancelAllOperations];
-
+ [operationQueue cancelAllOperations]; // async call
+ [NSThread detachNewThreadWithName:SPCtxt(@"SPExportController cancelExport: waiting for empty queue", tableDocumentInstance) target:self selector:@selector(_waitUntilQueueIsEmpty:) object:sender];
+}
+
+- (void)_waitUntilQueueIsEmpty:(id)sender
+{
+ [sender retain];
+ [operationQueue waitUntilAllOperationsAreFinished];
+ [self performSelectorOnMainThread:@selector(_queueIsEmpty:) withObject:sender waitUntilDone:NO];
+ [sender release];
+}
+
+- (void)_queueIsEmpty:(id)sender
+{
// Loop the cached export file paths and remove them from disk if they exist
for (SPExportFile *file in exportFiles)
{