summaryrefslogtreecommitdiff
path: root/platform/android/src/run_loop.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-03-10 14:03:04 -0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-04-06 04:52:51 -0300
commit10b503eabfb3c0c53b9a4bef8849f2511ae0ac16 (patch)
tree5b46f173fb4b6b021f5c4ff00b0c91eec8285c41 /platform/android/src/run_loop.cpp
parent74a1d3c1641673409a7058869249cf260870b9c0 (diff)
downloadqtlocation-mapboxgl-10b503eabfb3c0c53b9a4bef8849f2511ae0ac16.tar.gz
[android] Attach thread on the RunLoop
Needed because Looper could be used by Java and it would crash complaining that we didn't detach otherwise.
Diffstat (limited to 'platform/android/src/run_loop.cpp')
-rw-r--r--platform/android/src/run_loop.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/platform/android/src/run_loop.cpp b/platform/android/src/run_loop.cpp
index b3b1fd2d95..e05d27a088 100644
--- a/platform/android/src/run_loop.cpp
+++ b/platform/android/src/run_loop.cpp
@@ -1,5 +1,6 @@
#include "run_loop_impl.hpp"
+#include <mbgl/util/thread_context.hpp>
#include <mbgl/util/thread_local.hpp>
#include <android/looper.h>
@@ -74,6 +75,9 @@ RunLoop* RunLoop::Get() {
}
RunLoop::RunLoop(Type) : impl(std::make_unique<Impl>()) {
+ using namespace mbgl::android;
+ impl->detach = attach_jni_thread(theJVM, &impl->env, ThreadContext::getName());
+
impl->loop = ALooper_prepare(0);
assert(impl->loop);
@@ -86,6 +90,9 @@ RunLoop::~RunLoop() {
current.set(nullptr);
ALooper_release(impl->loop);
+
+ using namespace mbgl::android;
+ detach_jni_thread(theJVM, &impl->env, impl->detach);
}
LOOP_HANDLE RunLoop::getLoopHandle() {