Fix QJniObject::registerNativeMethods use of global reference

registerNativeMethods() should be using the local jclass from
findClass() instead of the global reference.

Task-number: QTBUG-89633
Change-Id: I469a9a1ecff95ab9948421baa5c88735ba7ad776
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
Assam Boudjelthia 2021-02-01 17:24:21 +02:00
parent 9f4098937b
commit c00ab6f8ea

View File

@ -221,14 +221,13 @@ bool QJniEnvironment::registerNativeMethods(const char *className, JNINativeMeth
if (!clazz)
return false;
jclass gClazz = static_cast<jclass>(d->jniEnv->NewGlobalRef(clazz));
if (d->jniEnv->RegisterNatives(gClazz, methods, size / sizeof(methods[0])) < 0) {
if (d->jniEnv->RegisterNatives(clazz, methods, size / sizeof(methods[0])) < 0) {
exceptionCheckAndClear();
d->jniEnv->DeleteLocalRef(clazz);
return false;
}
d->jniEnv->DeleteLocalRef(gClazz);
d->jniEnv->DeleteLocalRef(clazz);
return true;
}