aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-07-21 19:55:35 +0000
committerrowanbeentje <rowan@beent.je>2010-07-21 19:55:35 +0000
commit1a31d19e675a18d93bf294c765af83a9b8557821 (patch)
tree0a202c5e69954c0c570e8efdc2a65c4626a03213
parentf43bd95832a0a1bb4ef486f1980d4d3b5edaa4b8 (diff)
downloadsequelpro-1a31d19e675a18d93bf294c765af83a9b8557821.tar.gz
sequelpro-1a31d19e675a18d93bf294c765af83a9b8557821.tar.bz2
sequelpro-1a31d19e675a18d93bf294c765af83a9b8557821.zip
- Improve thread safety when altering task cancellation state
-rw-r--r--Source/SPDatabaseDocument.m6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index a34d5b94..a140db3f 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -1437,6 +1437,9 @@
// If no task is active, return
if (!_isWorkingLevel) return;
+ // Ensure call on the main thread
+ if (![NSThread isMainThread]) return [[self onMainThread] enableTaskCancellationWithTitle:buttonTitle callbackObject:callbackObject callbackFunction:callbackFunction];
+
if (callbackObject && callbackFunction) {
taskCancellationCallbackObject = callbackObject;
taskCancellationCallbackSelector = callbackFunction;
@@ -1456,6 +1459,9 @@
// If no task is active, return
if (!_isWorkingLevel) return;
+
+ // Ensure call on the main thread
+ if (![NSThread isMainThread]) return [[self onMainThread] disableTaskCancellation];
taskCanBeCancelled = NO;
taskCancellationCallbackObject = nil;