Fixed QJNIEnvironment reference counting.

Change-Id: I02369e0c6472375efeffed577d39b764c591e025
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Yoann Lopes 2013-09-24 15:31:23 +02:00 committed by The Qt Project
parent 0b1e30aee4
commit 445efa40a2

View File

@ -160,10 +160,12 @@ QJNIEnvironmentPrivate::QJNIEnvironmentPrivate()
: jniEnv(0)
{
JavaVM *vm = QtAndroidPrivate::javaVM();
if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) != JNI_EDETACHED)
return;
if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) == JNI_EDETACHED) {
if (vm->AttachCurrentThread(&jniEnv, 0) < 0)
return;
}
if (vm->AttachCurrentThread(&jniEnv, 0) < 0)
if (!jniEnv)
return;
if (!refCount->hasLocalData())