summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-04-05 22:37:45 +0200
committerTobrun <tobrun@mapbox.com>2018-04-10 15:49:01 +0200
commit451e6bc8a0ca3e2d2f1629d5351cc3724648b97e (patch)
tree134af536290a99cd1c1a3ae23faa30596d59a6f6
parent4f809d6626cf661ecc3993f7ffa49b338d8c63ad (diff)
downloadqtlocation-mapboxgl-451e6bc8a0ca3e2d2f1629d5351cc3724648b97e.tar.gz
[android] - add delete local refs calls for make jni strings
-rw-r--r--platform/android/src/offline/offline_manager.cpp8
-rw-r--r--platform/android/src/offline/offline_region.cpp12
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.cpp4
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);