From 5f202e1c4441a05f099d2cc998e5742d0dfd81a3 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Mon, 13 Feb 2012 19:59:44 +0300 Subject: [PATCH] [android] Fixed crash in downloader - local JNI reference had become invalid between calls --- android/jni/com/mapswithme/platform/HttpThread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/jni/com/mapswithme/platform/HttpThread.cpp b/android/jni/com/mapswithme/platform/HttpThread.cpp index 0fd9b8656a..f3a4387b27 100644 --- a/android/jni/com/mapswithme/platform/HttpThread.cpp +++ b/android/jni/com/mapswithme/platform/HttpThread.cpp @@ -24,8 +24,8 @@ public: jmethodID methodId = env->GetMethodID(klass, "", "(JLjava/lang/String;JJJLjava/lang/String;)V"); ASSERT(methodId, ("Can't find java constructor in com/mapswithme/maps/downloader/DownloadChunkTask")); - m_self = env->NewObject(klass, methodId, reinterpret_cast(&cb), - env->NewStringUTF(url.c_str()), beg, end, expectedFileSize, env->NewStringUTF(pb.c_str())); + m_self = env->NewGlobalRef(env->NewObject(klass, methodId, reinterpret_cast(&cb), + env->NewStringUTF(url.c_str()), beg, end, expectedFileSize, env->NewStringUTF(pb.c_str()))); methodId = env->GetMethodID(klass, "start", "()V"); ASSERT(methodId, ("Can't find java method 'start' in com/mapswithme/maps/downloader/DownloadChunkTask")); @@ -43,6 +43,7 @@ public: ASSERT(methodId, ("Can't find java method 'cancel' in com/mapswithme/maps/downloader/DownloadChunkTask")); env->CallBooleanMethod(m_self, methodId, false); + env->DeleteGlobalRef(m_self); } };