Commit e0b68dfe authored by Christian Strømme's avatar Christian Strømme
Browse files

Fix QAndroidJniEnvironment test


The QAndroidJniEnvironment class does not detach when it goes out of
scope. Detaching will only happen if explicitly done, or if the thread
we attached on dies.

Fixes: QTBUG-73570
Change-Id: Iac749c7f3bf8fcee99f70c06123eb3c88315e261
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Showing with 4 additions and 3 deletions
...@@ -66,9 +66,10 @@ void tst_QAndroidJniEnvironment::jniEnv() ...@@ -66,9 +66,10 @@ void tst_QAndroidJniEnvironment::jniEnv()
env->ExceptionClear(); env->ExceptionClear();
} }
// The environment should automatically be detached when QAndroidJniEnvironment goes out of scope // The env does not detach automatically, even if it goes out of scope. The only way it can
JNIEnv *jni = 0; // be detached is if it's done explicitly, or if the thread we attached to gets killed (TLS clean-up).
QCOMPARE(javaVM->GetEnv((void**)&jni, JNI_VERSION_1_6), JNI_EDETACHED); JNIEnv *jni = nullptr;
QCOMPARE(javaVM->GetEnv((void**)&jni, JNI_VERSION_1_6), JNI_OK);
} }
void tst_QAndroidJniEnvironment::javaVM() void tst_QAndroidJniEnvironment::javaVM()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment