summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-11-22 13:18:22 -0800
committerChris Loer <chris.loer@mapbox.com>2017-11-27 14:42:44 -0800
commit5da5ba7706eb28b359b5d781bd2c769e336ca5ca (patch)
tree0afc10d7c2066367a8e68adbb80d1133fbfe0a8e /platform/qt
parentd8bcc943c50b1030f8b090d28b023ff7c40afd9c (diff)
downloadqtlocation-mapboxgl-5da5ba7706eb28b359b5d781bd2c769e336ca5ca.tar.gz
[core, ios, qt, android] Close race condition in RunLoop (issue #9620)
Because a message we queue from the foreground may cause the background to complete, exit, and tear down the AsyncTask, we have to block queue processing until we've finished our call to AsyncTask::send(). Broadening the scope of a mutex is scary, but I audited the code of our four implementations of AsyncTask and I don't see any way this could cause a deadlock.
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/src/run_loop.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/platform/qt/src/run_loop.cpp b/platform/qt/src/run_loop.cpp
index 71ea19032a..af0c50ebb9 100644
--- a/platform/qt/src/run_loop.cpp
+++ b/platform/qt/src/run_loop.cpp
@@ -53,8 +53,10 @@ LOOP_HANDLE RunLoop::getLoopHandle() {
}
void RunLoop::push(std::shared_ptr<WorkTask> task) {
- withMutex([&] { queue.push(task); });
- impl->async->send();
+ withMutex([&] {
+ queue.push(std::move(task));
+ impl->async->send();
+ });
}
void RunLoop::run() {