Android: take JavaVM() from QJniEnvironment and not QtAndroidPrivate

Task-number: QTBUG-89482
Change-Id: Idfd442afc90c00e672b28b43c78c789813f46c7d
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit 3348107c038cbac724e33d6bb30671ddddc1505a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Assam Boudjelthia 2021-02-10 13:18:43 +02:00 committed by Qt Cherry-pick Bot
parent f576e22f6e
commit afd74eb7fb
2 changed files with 5 additions and 4 deletions

View File

@ -53,7 +53,8 @@
#endif
#ifdef Q_OS_ANDROID
# include <private/qjnihelpers_p.h>
#include <private/qjnihelpers_p.h>
#include <QtCore/qjnienvironment.h>
#endif
QT_BEGIN_NAMESPACE
@ -244,7 +245,7 @@ bool QLibraryPrivate::load_sys()
if (hnd) {
using JniOnLoadPtr = jint (*)(JavaVM *vm, void *reserved);
JniOnLoadPtr jniOnLoad = reinterpret_cast<JniOnLoadPtr>(dlsym(hnd, "JNI_OnLoad"));
if (jniOnLoad && jniOnLoad(QtAndroidPrivate::javaVM(), nullptr) == JNI_ERR) {
if (jniOnLoad && jniOnLoad(QJniEnvironment::javaVM(), nullptr) == JNI_ERR) {
dlclose(hnd);
hnd = nullptr;
}

View File

@ -527,8 +527,8 @@ static jboolean startQtApplication(JNIEnv */*env*/, jclass /*clazz*/)
args.version = JNI_VERSION_1_6;
args.name = "QtMainThread";
args.group = NULL;
JavaVM *vm = QtAndroidPrivate::javaVM();
if (vm != 0)
JavaVM *vm = QJniEnvironment::javaVM();
if (vm)
vm->AttachCurrentThread(&env, &args);
}