Improve handling of cancelled HTTP requests

Fix a memory leak of NativeMapView Java object
This commit is contained in:
Leith Bade
2015-09-17 17:34:13 -07:00
parent 6e55dd575e
commit 19e7d154bb
4 changed files with 27 additions and 18 deletions

View File

@@ -73,7 +73,7 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a
return;
}
obj = env->NewGlobalRef(obj_);
obj = env->NewWeakGlobalRef(obj_);
if (obj == nullptr) {
env->ExceptionDescribe();
return;
@@ -93,7 +93,7 @@ NativeMapView::~NativeMapView() {
JNIEnv *env = nullptr;
ret = vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
if (ret == JNI_OK) {
env->DeleteGlobalRef(obj);
env->DeleteWeakGlobalRef(obj);
} else {
mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret);
throw new std::runtime_error("GetEnv() failed");