diff options
author | rowanbeentje <rowan@beent.je> | 2010-07-21 19:55:35 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-07-21 19:55:35 +0000 |
commit | 1a31d19e675a18d93bf294c765af83a9b8557821 (patch) | |
tree | 0a202c5e69954c0c570e8efdc2a65c4626a03213 | |
parent | f43bd95832a0a1bb4ef486f1980d4d3b5edaa4b8 (diff) | |
download | sequelpro-1a31d19e675a18d93bf294c765af83a9b8557821.tar.gz sequelpro-1a31d19e675a18d93bf294c765af83a9b8557821.tar.bz2 sequelpro-1a31d19e675a18d93bf294c765af83a9b8557821.zip |
- Improve thread safety when altering task cancellation state
-rw-r--r-- | Source/SPDatabaseDocument.m | 6 |
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; |