diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2018-04-05 22:37:45 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-04-09 20:14:45 +0200 |
commit | c1dabbde8d58143b1f7f64eddeb75c06ab417d32 (patch) | |
tree | 915e78248b6c3ee3bb0cfba74f750e7103676e01 /platform/android | |
parent | 14423a225b2aa1d24cc7a889665358898fc3c66b (diff) | |
download | qtlocation-mapboxgl-c1dabbde8d58143b1f7f64eddeb75c06ab417d32.tar.gz |
[android] - add delete local refs calls for make jni strings
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/src/offline/offline_manager.cpp | 8 | ||||
-rw-r--r-- | platform/android/src/offline/offline_region.cpp | 12 | ||||
-rw-r--r-- | platform/android/src/snapshotter/map_snapshotter.cpp | 4 |
3 files changed, 18 insertions, 6 deletions
diff --git a/platform/android/src/offline/offline_manager.cpp b/platform/android/src/offline/offline_manager.cpp index 02871e7fdf..4960ae2845 100644 --- a/platform/android/src/offline/offline_manager.cpp +++ b/platform/android/src/offline/offline_manager.cpp @@ -102,7 +102,9 @@ void OfflineManager::ListOfflineRegionsCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make<jni::String>(env, message)); + auto jmessage = jni::Make<jni::String>(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineManager::ListOfflineRegionsCallback::onList(jni::JNIEnv& env, @@ -138,7 +140,9 @@ void OfflineManager::CreateOfflineRegionCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make<jni::String>(env, message)); + auto jmessage = jni::Make<jni::String>(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineManager::CreateOfflineRegionCallback::onCreate(jni::JNIEnv& env, diff --git a/platform/android/src/offline/offline_region.cpp b/platform/android/src/offline/offline_region.cpp index 856434d266..27de76fb00 100644 --- a/platform/android/src/offline/offline_region.cpp +++ b/platform/android/src/offline/offline_region.cpp @@ -239,7 +239,9 @@ void OfflineRegion::OfflineRegionStatusCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make<jni::String>(env, message)); + auto jmessage = jni::Make<jni::String>(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineRegion::OfflineRegionStatusCallback::onStatus(jni::JNIEnv& env, @@ -267,7 +269,9 @@ void OfflineRegion::OfflineRegionDeleteCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make<jni::String>(env, message)); + auto jmessage = jni::Make<jni::String>(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineRegion::OfflineRegionDeleteCallback::onDelete(jni::JNIEnv& env, jni::Object<OfflineRegion::OfflineRegionDeleteCallback> callback) { @@ -289,7 +293,9 @@ void OfflineRegion::OfflineRegionUpdateMetadataCallback::onError(jni::JNIEnv& en std::exception_ptr error) { static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make<jni::String>(env, message)); + auto jmessage = jni::Make<jni::String>(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineRegion::OfflineRegionUpdateMetadataCallback::onUpdate(jni::JNIEnv& env, diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index 71f8b4f4c0..a006953d36 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -71,7 +71,9 @@ void MapSnapshotter::start(JNIEnv& env) { if (err) { // error handler callback static auto onSnapshotFailed = javaClass.GetMethod<void (jni::String)>(*_env, "onSnapshotFailed"); - javaPeer->Call(*_env, onSnapshotFailed, jni::Make<jni::String>(*_env, util::toString(err))); + auto message = jni::Make<jni::String>(*_env, util::toString(err)); + javaPeer->Call(*_env, onSnapshotFailed, message); + jni::DeleteLocalRef(*_env, message); } else { // Create the wrapper auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn); |