aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-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;