diff options
author | Osana Babayan <32496536+osana@users.noreply.github.com> | 2018-02-21 11:01:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-21 11:01:56 -0500 |
commit | c2d9d6a4235d5bce5c10b40b3f8cfaeb331d7878 (patch) | |
tree | c3841b892bf56af461fec5c484a21c031ee0755e | |
parent | 06213d9145d3b20b63e235cc25678fd76dc296d0 (diff) | |
download | qtlocation-mapboxgl-c2d9d6a4235d5bce5c10b40b3f8cfaeb331d7878.tar.gz |
[android] jni clean up - missing a couple DeleteLocalRef
-rw-r--r-- | platform/android/src/conversion/collection.hpp | 1 | ||||
-rw-r--r-- | platform/android/src/file_source.cpp | 5 | ||||
-rw-r--r-- | platform/android/src/geojson/feature_collection.cpp | 1 | ||||
-rw-r--r-- | platform/android/src/geojson/point.cpp | 1 | ||||
-rw-r--r-- | platform/android/src/map/camera_position.cpp | 4 | ||||
-rw-r--r-- | platform/android/src/map/image.cpp | 4 |
6 files changed, 11 insertions, 5 deletions
diff --git a/platform/android/src/conversion/collection.hpp b/platform/android/src/conversion/collection.hpp index 549121c7ef..2b953e73f4 100644 --- a/platform/android/src/conversion/collection.hpp +++ b/platform/android/src/conversion/collection.hpp @@ -28,6 +28,7 @@ inline jni::jobject* toArrayList(JNIEnv& env, jni::jarray<T>& array) { inline std::vector<std::string> toVector(JNIEnv& env, jni::jarray<jni::jobject>& array) { std::vector<std::string> vector; std::size_t len = jni::GetArrayLength(env, array); + vector.reserve(len); for (std::size_t i = 0; i < len; i++) { jni::jstring* jstr = reinterpret_cast<jni::jstring*>(jni::GetObjectArrayElement(env, array, i)); diff --git a/platform/android/src/file_source.cpp b/platform/android/src/file_source.cpp index 728935c03f..42c03b0974 100644 --- a/platform/android/src/file_source.cpp +++ b/platform/android/src/file_source.cpp @@ -132,8 +132,11 @@ jni::Class<FileSource::ResourceTransformCallback> FileSource::ResourceTransformC std::string FileSource::ResourceTransformCallback::onURL(jni::JNIEnv& env, jni::Object<FileSource::ResourceTransformCallback> callback, int kind, std::string url_) { static auto method = FileSource::ResourceTransformCallback::javaClass.GetMethod<jni::String (jni::jint, jni::String)>(env, "onURL"); auto url = jni::Make<jni::String>(env, url_); + url = callback.Call(env, method, kind, url); - return jni::Make<std::string>(env, url); + auto urlStr = jni::Make<std::string>(env, url); + jni::DeleteLocalRef(env, url); + return urlStr; } } // namespace android diff --git a/platform/android/src/geojson/feature_collection.cpp b/platform/android/src/geojson/feature_collection.cpp index 06f8f10b9a..18a41d48fa 100644 --- a/platform/android/src/geojson/feature_collection.cpp +++ b/platform/android/src/geojson/feature_collection.cpp @@ -1,4 +1,3 @@ -#include <android/log.h> #include "feature_collection.hpp" #include "feature.hpp" diff --git a/platform/android/src/geojson/point.cpp b/platform/android/src/geojson/point.cpp index d064547145..e95376cd2e 100644 --- a/platform/android/src/geojson/point.cpp +++ b/platform/android/src/geojson/point.cpp @@ -1,4 +1,3 @@ -#include <android/log.h> #include "point.hpp" #include "../java/util.hpp" #include "../java_types.hpp" diff --git a/platform/android/src/map/camera_position.cpp b/platform/android/src/map/camera_position.cpp index 1fc5f9789f..01ffc6530b 100644 --- a/platform/android/src/map/camera_position.cpp +++ b/platform/android/src/map/camera_position.cpp @@ -33,7 +33,9 @@ mbgl::CameraOptions CameraPosition::getCameraOptions(jni::JNIEnv& env, jni::Obje static auto tilt = CameraPosition::javaClass.GetField<jni::jdouble>(env, "tilt"); static auto zoom = CameraPosition::javaClass.GetField<jni::jdouble>(env, "zoom"); - auto center = LatLng::getLatLng(env, position.Get(env, target)); + auto jtarget = position.Get(env, target); + auto center = LatLng::getLatLng(env, jtarget); + jni::DeleteLocalRef(env, jtarget); return mbgl::CameraOptions { center, diff --git a/platform/android/src/map/image.cpp b/platform/android/src/map/image.cpp index 5f5c90eddd..52e0e0d255 100644 --- a/platform/android/src/map/image.cpp +++ b/platform/android/src/map/image.cpp @@ -16,7 +16,9 @@ mbgl::style::Image Image::getImage(jni::JNIEnv& env, jni::Object<Image> image) { auto width = image.Get(env, widthField); auto pixelRatio = image.Get(env, pixelRatioField); auto pixels = image.Get(env, bufferField); - auto name = jni::Make<std::string>(env, image.Get(env, nameField)); + auto jName = image.Get(env, nameField); + auto name = jni::Make<std::string>(env, jName); + jni::DeleteLocalRef(env, jName); jni::NullCheck(env, &pixels); std::size_t size = pixels.Length(env); |