diff options
-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); |