summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qjnienvironment.cpp
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2021-02-01 17:24:21 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2021-02-02 10:32:36 +0200
commitc00ab6f8eaa3cdc9a29dd103c91b2eaf212cac9f (patch)
treeb9e61ce7158c3bbcfbcf82b409a69f88fd4b5d72 /src/corelib/kernel/qjnienvironment.cpp
parent9f4098937be1325c12a224de18974352b14aee38 (diff)
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>
Diffstat (limited to 'src/corelib/kernel/qjnienvironment.cpp')
-rw-r--r--src/corelib/kernel/qjnienvironment.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/corelib/kernel/qjnienvironment.cpp b/src/corelib/kernel/qjnienvironment.cpp
index 04676cc29c..4e52f33e0c 100644
--- a/src/corelib/kernel/qjnienvironment.cpp
+++ b/src/corelib/kernel/qjnienvironment.cpp
@@ -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;
}