[android] added missing delete local references
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <android/log.h>
|
||||
#include "feature_collection.hpp"
|
||||
|
||||
#include "feature.hpp"
|
||||
@@ -7,19 +8,23 @@ namespace android {
|
||||
namespace geojson {
|
||||
|
||||
mbgl::FeatureCollection FeatureCollection::convert(jni::JNIEnv& env, jni::Object<FeatureCollection> jCollection) {
|
||||
auto jFeatureList = FeatureCollection::features(env, jCollection);
|
||||
auto jFeatures = java::util::List::toArray<Feature>(env, jFeatureList);
|
||||
auto size = size_t(jFeatures.Length(env));
|
||||
|
||||
auto collection = mbgl::FeatureCollection();
|
||||
collection.reserve(size);
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
auto jFeature = jFeatures.Get(env, i);
|
||||
collection.push_back(Feature::convert(env, jFeature));
|
||||
jni::DeleteLocalRef(env, jFeature);
|
||||
if (jCollection) {
|
||||
auto jFeatureList = FeatureCollection::features(env, jCollection);
|
||||
auto jFeatures = java::util::List::toArray<Feature>(env, jFeatureList);
|
||||
auto size = size_t(jFeatures.Length(env));
|
||||
collection.reserve(size);
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
auto jFeature = jFeatures.Get(env, i);
|
||||
collection.push_back(Feature::convert(env, jFeature));
|
||||
jni::DeleteLocalRef(env, jFeature);
|
||||
}
|
||||
|
||||
jni::DeleteLocalRef(env, jFeatures);
|
||||
jni::DeleteLocalRef(env, jFeatureList);
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ mapbox::geojson::line_string LineString::convert(jni::JNIEnv &env, jni::Object<j
|
||||
|
||||
if (jPointList) {
|
||||
auto jPointArray = java::util::List::toArray<Point>(env, jPointList);
|
||||
|
||||
auto size = jPointArray.Length(env);
|
||||
lineString.reserve(size);
|
||||
|
||||
for (std::size_t i = 0; i < size; i++) {
|
||||
auto jPoint = jPointArray.Get(env, i);
|
||||
lineString.push_back(Point::convert(env, jPoint));
|
||||
|
||||
@@ -22,8 +22,8 @@ mapbox::geojson::multi_polygon MultiPolygon::convert(jni::JNIEnv &env, jni::Obje
|
||||
jni::DeleteLocalRef(env, jPositionListsList);
|
||||
}
|
||||
|
||||
jni::DeleteLocalRef(env, jPointListsListList);
|
||||
jni::DeleteLocalRef(env, jPointListsListArray);
|
||||
jni::DeleteLocalRef(env, jPointListsListList);
|
||||
}
|
||||
|
||||
return multiPolygon;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <android/log.h>
|
||||
#include "point.hpp"
|
||||
#include "../java/util.hpp"
|
||||
#include "../java_types.hpp"
|
||||
#include "../style/value.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
@@ -19,17 +21,23 @@ mapbox::geojson::point Point::convert(jni::JNIEnv &env, jni::Object<Point> jPoin
|
||||
}
|
||||
|
||||
mapbox::geojson::point Point::convert(jni::JNIEnv &env, jni::Object<java::util::List/*<Double>*/> jDoubleList) {
|
||||
auto jDoubleArray = java::util::List::toArray<double>(env, jDoubleList);
|
||||
mapbox::geojson::point point;
|
||||
|
||||
jni::jdouble lon = jni::CallMethod<jni::jdouble>(env,
|
||||
jDoubleArray.Get(env, 0),
|
||||
*java::Number::doubleValueMethodId);
|
||||
jni::jdouble lat = jni::CallMethod<jni::jdouble>(env,
|
||||
jDoubleArray.Get(env, 1),
|
||||
*java::Number::doubleValueMethodId);
|
||||
mapbox::geojson::point point(lon, lat);
|
||||
jni::DeleteLocalRef(env, jDoubleArray);
|
||||
if (jDoubleList) {
|
||||
auto jDoubleArray = java::util::List::toArray<jobject>(env, jDoubleList);
|
||||
|
||||
auto lonObject = jDoubleArray.Get(env, 0);
|
||||
auto latObject = jDoubleArray.Get(env, 1);
|
||||
|
||||
point.x = jni::CallMethod<jni::jdouble>(env, lonObject,
|
||||
*java::Number::doubleValueMethodId);
|
||||
point.y = jni::CallMethod<jni::jdouble>(env, latObject,
|
||||
*java::Number::doubleValueMethodId);
|
||||
|
||||
jni::DeleteLocalRef(env, lonObject);
|
||||
jni::DeleteLocalRef(env, latObject);
|
||||
jni::DeleteLocalRef(env, jDoubleArray);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user