From 1a31d19e675a18d93bf294c765af83a9b8557821 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 21 Jul 2010 19:55:35 +0000 Subject: - Improve thread safety when altering task cancellation state --- Source/SPDatabaseDocument.m | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source') 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; -- cgit v1.2.3