diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-11-13 16:06:26 -0800 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-11-22 13:56:38 -0800 |
commit | f06ebcc96791838acb485fc37877725a443ca8f5 (patch) | |
tree | 54b32821974703a3fae30ee86668bba4115f06e9 /platform/android/src/style/sources/vector_source.cpp | |
parent | 3067b77c650f5dea0c00a7a92a9fc927e028c742 (diff) | |
download | qtlocation-mapboxgl-f06ebcc96791838acb485fc37877725a443ca8f5.tar.gz |
[android] Reuse Java Source objects by holding on to a strong reference in the C++ peer.
Diffstat (limited to 'platform/android/src/style/sources/vector_source.cpp')
-rw-r--r-- | platform/android/src/style/sources/vector_source.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/platform/android/src/style/sources/vector_source.cpp b/platform/android/src/style/sources/vector_source.cpp index 7fe45441bd..9a9548d283 100644 --- a/platform/android/src/style/sources/vector_source.cpp +++ b/platform/android/src/style/sources/vector_source.cpp @@ -30,8 +30,10 @@ namespace android { ) { } - VectorSource::VectorSource(mbgl::style::VectorSource& coreSource) - : Source(coreSource) { + VectorSource::VectorSource(jni::JNIEnv& env, + mbgl::style::Source& coreSource, + AndroidRendererFrontend& frontend) + : Source(env, coreSource, createJavaPeer(env), frontend) { } VectorSource::~VectorSource() = default; @@ -56,9 +58,9 @@ namespace android { jni::Class<VectorSource> VectorSource::javaClass; - jni::jobject* VectorSource::createJavaPeer(jni::JNIEnv& env) { + jni::Object<Source> VectorSource::createJavaPeer(jni::JNIEnv& env) { static auto constructor = VectorSource::javaClass.template GetConstructor<jni::jlong>(env); - return VectorSource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)); + return jni::Object<Source>(VectorSource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get()); } void VectorSource::registerNative(jni::JNIEnv& env) { |