Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add missing jni::DeleteLocalRef #11608

Merged
merged 1 commit into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions platform/android/src/offline/offline_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions platform/android/src/offline/offline_region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion platform/android/src/snapshotter/map_snapshotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down