Merge integration refs/builds/qtci/dev/1618405176
This commit is contained in:
commit
1d59fe368a
@ -136,21 +136,31 @@ QJniEnvironment::~QJniEnvironment()
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn JNIEnv *QJniEnvironment::operator->()
|
||||
\fn JNIEnv *QJniEnvironment::operator->() const
|
||||
|
||||
Provides access to the QJniEnvironment's JNIEnv pointer.
|
||||
Provides access to the JNI Environment's \c JNIEnv pointer.
|
||||
*/
|
||||
JNIEnv *QJniEnvironment::operator->()
|
||||
JNIEnv *QJniEnvironment::operator->() const
|
||||
{
|
||||
return d->jniEnv;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QJniEnvironment::operator JNIEnv *() const
|
||||
\fn JNIEnv &QJniEnvironment::operator*() const
|
||||
|
||||
Returns the JNI Environment pointer.
|
||||
Returns the JNI Environment's \c JNIEnv object.
|
||||
*/
|
||||
QJniEnvironment::operator JNIEnv* () const
|
||||
JNIEnv &QJniEnvironment::operator*() const
|
||||
{
|
||||
return *d->jniEnv;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn JNIEnv *QJniEnvironment::jniEnv()
|
||||
|
||||
Returns the JNI Environment's \c JNIEnv pointer.
|
||||
*/
|
||||
JNIEnv *QJniEnvironment::jniEnv() const
|
||||
{
|
||||
return d->jniEnv;
|
||||
}
|
||||
|
@ -60,8 +60,9 @@ class Q_CORE_EXPORT QJniEnvironment
|
||||
public:
|
||||
QJniEnvironment();
|
||||
~QJniEnvironment();
|
||||
JNIEnv *operator->();
|
||||
operator JNIEnv *() const;
|
||||
JNIEnv *operator->() const;
|
||||
JNIEnv &operator*() const;
|
||||
JNIEnv *jniEnv() const;
|
||||
jclass findClass(const char *className);
|
||||
static JavaVM *javaVM();
|
||||
bool registerNativeMethods(const char *className, JNINativeMethod methods[], int size);
|
||||
@ -74,7 +75,6 @@ public:
|
||||
bool checkAndClearExceptions(OutputMode outputMode = OutputMode::Verbose);
|
||||
static bool checkAndClearExceptions(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose);
|
||||
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(QJniEnvironment)
|
||||
QScopedPointer<QJniEnvironmentPrivate> d;
|
||||
|
@ -489,7 +489,7 @@ jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
|
||||
}
|
||||
|
||||
if (!clazz) // We didn't get an env. pointer or we got one with the WRONG class loader...
|
||||
clazz = loadClass(classDotEnc, QJniEnvironment(), true);
|
||||
clazz = loadClass(classDotEnc, QJniEnvironment().jniEnv(), true);
|
||||
|
||||
return clazz;
|
||||
}
|
||||
@ -538,11 +538,11 @@ QJniObject::QJniObject(const char *className)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
d->m_className = toBinaryEncClassName(className);
|
||||
d->m_jclass = loadClass(d->m_className, env, true);
|
||||
d->m_jclass = loadClass(d->m_className, env.jniEnv(), true);
|
||||
d->m_own_jclass = false;
|
||||
if (d->m_jclass) {
|
||||
// get default constructor
|
||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", "()V");
|
||||
jmethodID constructorId = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, "<init>", "()V");
|
||||
if (constructorId) {
|
||||
jobject obj = env->NewObject(d->m_jclass, constructorId);
|
||||
if (obj) {
|
||||
@ -571,10 +571,10 @@ QJniObject::QJniObject(const char *className, const char *signature, ...)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
d->m_className = toBinaryEncClassName(className);
|
||||
d->m_jclass = loadClass(d->m_className, env, true);
|
||||
d->m_jclass = loadClass(d->m_className, env.jniEnv(), true);
|
||||
d->m_own_jclass = false;
|
||||
if (d->m_jclass) {
|
||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", signature);
|
||||
jmethodID constructorId = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, "<init>", signature);
|
||||
if (constructorId) {
|
||||
va_list args;
|
||||
va_start(args, signature);
|
||||
@ -593,10 +593,10 @@ QJniObject::QJniObject(const char *className, const char *signature, const QVaLi
|
||||
{
|
||||
QJniEnvironment env;
|
||||
d->m_className = toBinaryEncClassName(className);
|
||||
d->m_jclass = loadClass(d->m_className, env, true);
|
||||
d->m_jclass = loadClass(d->m_className, env.jniEnv(), true);
|
||||
d->m_own_jclass = false;
|
||||
if (d->m_jclass) {
|
||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", signature);
|
||||
jmethodID constructorId = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, "<init>", signature);
|
||||
if (constructorId) {
|
||||
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
||||
if (obj) {
|
||||
@ -626,7 +626,7 @@ QJniObject::QJniObject(jclass clazz, const char *signature, ...)
|
||||
if (clazz) {
|
||||
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||
if (d->m_jclass) {
|
||||
jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", signature);
|
||||
jmethodID constructorId = getMethodID(env.jniEnv(), d->m_jclass, "<init>", signature);
|
||||
if (constructorId) {
|
||||
va_list args;
|
||||
va_start(args, signature);
|
||||
@ -658,7 +658,7 @@ QJniObject::QJniObject(jclass clazz)
|
||||
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||
if (d->m_jclass) {
|
||||
// get default constructor
|
||||
jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", "()V");
|
||||
jmethodID constructorId = getMethodID(env.jniEnv(), d->m_jclass, "<init>", "()V");
|
||||
if (constructorId) {
|
||||
jobject obj = env->NewObject(d->m_jclass, constructorId);
|
||||
if (obj) {
|
||||
@ -676,7 +676,7 @@ QJniObject::QJniObject(jclass clazz, const char *signature, const QVaListPrivate
|
||||
if (clazz) {
|
||||
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||
if (d->m_jclass) {
|
||||
jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", signature);
|
||||
jmethodID constructorId = getMethodID(env.jniEnv(), d->m_jclass, "<init>", signature);
|
||||
if (constructorId) {
|
||||
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
||||
if (obj) {
|
||||
@ -772,7 +772,7 @@ QJniObject QJniObject::callObjectMethodV(const char *methodName,
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jobject res = nullptr;
|
||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||
if (id) {
|
||||
res = env->CallObjectMethodV(d->m_jobject, id, args);
|
||||
if (env.checkAndClearExceptions()) {
|
||||
@ -793,9 +793,9 @@ QJniObject QJniObject::callStaticObjectMethodV(const char *className,
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jobject res = nullptr;
|
||||
jclass clazz = loadClass(className, env);
|
||||
jclass clazz = loadClass(className, env.jniEnv());
|
||||
if (clazz) {
|
||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className),
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className),
|
||||
methodName, signature, true);
|
||||
if (id) {
|
||||
res = env->CallStaticObjectMethodV(clazz, id, args);
|
||||
@ -817,7 +817,7 @@ QJniObject QJniObject::callStaticObjectMethodV(jclass clazz,
|
||||
va_list args)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
||||
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||
if (!id)
|
||||
return QJniObject();
|
||||
|
||||
@ -840,7 +840,7 @@ template <>
|
||||
Q_CORE_EXPORT void QJniObject::callMethod<void>(const char *methodName, const char *signature, ...) const
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||
if (id) {
|
||||
va_list args;
|
||||
va_start(args, signature);
|
||||
@ -885,9 +885,9 @@ Q_CORE_EXPORT void QJniObject::callStaticMethod<void>(const char *className,
|
||||
...)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jclass clazz = loadClass(className, env);
|
||||
jclass clazz = loadClass(className, env.jniEnv());
|
||||
if (clazz) {
|
||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className),
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className),
|
||||
methodName, signature, true);
|
||||
if (id) {
|
||||
va_list args;
|
||||
@ -936,7 +936,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethod<void>(jclass clazz,
|
||||
{
|
||||
QJniEnvironment env;
|
||||
if (clazz) {
|
||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
||||
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||
if (id) {
|
||||
va_list args;
|
||||
va_start(args, signature);
|
||||
@ -954,9 +954,9 @@ Q_CORE_EXPORT void QJniObject::callStaticMethodV<void>(const char *className,
|
||||
va_list args)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jclass clazz = loadClass(className, env);
|
||||
jclass clazz = loadClass(className, env.jniEnv());
|
||||
if (clazz) {
|
||||
jmethodID id = getCachedMethodID(env, clazz,
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), clazz,
|
||||
toBinaryEncClassName(className), methodName,
|
||||
signature, true);
|
||||
if (id) {
|
||||
@ -973,7 +973,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethodV<void>(jclass clazz,
|
||||
va_list args)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
||||
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||
if (id) {
|
||||
env->CallStaticVoidMethodV(clazz, id, args);
|
||||
env.checkAndClearExceptions();
|
||||
@ -1002,7 +1002,7 @@ Q_CORE_EXPORT void QJniObject::callMethodV<void>(const char *methodName, const c
|
||||
va_list args) const
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||
if (id) {
|
||||
env->CallVoidMethodV(d->m_jobject, id, args);
|
||||
env.checkAndClearExceptions();
|
||||
@ -1015,7 +1015,7 @@ template <> Q_CORE_EXPORT Type QJniObject::callMethod<Type>(const char *methodNa
|
||||
{ \
|
||||
QJniEnvironment env; \
|
||||
Type res = 0; \
|
||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature); \
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature); \
|
||||
if (id) { \
|
||||
va_list args; \
|
||||
va_start(args, signature); \
|
||||
@ -1038,9 +1038,9 @@ template <> Q_CORE_EXPORT Type QJniObject::callStaticMethod<Type>(const char *cl
|
||||
{ \
|
||||
QJniEnvironment env; \
|
||||
Type res = 0; \
|
||||
jclass clazz = loadClass(className, env); \
|
||||
jclass clazz = loadClass(className, env.jniEnv()); \
|
||||
if (clazz) { \
|
||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, \
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className), methodName, \
|
||||
signature, true); \
|
||||
if (id) { \
|
||||
va_list args; \
|
||||
@ -1067,7 +1067,7 @@ template <> Q_CORE_EXPORT Type QJniObject::callStaticMethod<Type>(jclass clazz,
|
||||
QJniEnvironment env; \
|
||||
Type res = 0; \
|
||||
if (clazz) { \
|
||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true); \
|
||||
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true); \
|
||||
if (id) { \
|
||||
va_list args; \
|
||||
va_start(args, signature); \
|
||||
@ -1090,7 +1090,7 @@ Q_CORE_EXPORT Type QJniObject::callMethodV<Type>(const char *methodName, const c
|
||||
{\
|
||||
QJniEnvironment env;\
|
||||
Type res = 0;\
|
||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);\
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);\
|
||||
if (id) {\
|
||||
res = env->Call##MethodName##MethodV(d->m_jobject, id, args);\
|
||||
if (env.checkAndClearExceptions()) \
|
||||
@ -1106,9 +1106,9 @@ Q_CORE_EXPORT Type QJniObject::callStaticMethodV<Type>(const char *className,\
|
||||
{\
|
||||
QJniEnvironment env;\
|
||||
Type res = 0;\
|
||||
jclass clazz = loadClass(className, env);\
|
||||
jclass clazz = loadClass(className, env.jniEnv());\
|
||||
if (clazz) {\
|
||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName,\
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className), methodName,\
|
||||
signature, true);\
|
||||
if (id) {\
|
||||
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
|
||||
@ -1126,7 +1126,7 @@ Q_CORE_EXPORT Type QJniObject::callStaticMethodV<Type>(jclass clazz,\
|
||||
{\
|
||||
QJniEnvironment env;\
|
||||
Type res = 0;\
|
||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);\
|
||||
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);\
|
||||
if (id) {\
|
||||
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
|
||||
if (env.checkAndClearExceptions()) \
|
||||
@ -1162,7 +1162,7 @@ DECLARE_JNI_METHODS(Double, jdouble, "()D")
|
||||
QJniObject QJniObject::callObjectMethod(const char *methodName, const char *signature, ...) const
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||
if (id) {
|
||||
va_list args;
|
||||
va_start(args, signature);
|
||||
@ -1193,9 +1193,9 @@ QJniObject QJniObject::callStaticObjectMethod(const char *className,
|
||||
...)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jclass clazz = loadClass(className, env);
|
||||
jclass clazz = loadClass(className, env.jniEnv());
|
||||
if (clazz) {
|
||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className),
|
||||
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className),
|
||||
methodName, signature, true);
|
||||
if (id) {
|
||||
va_list args;
|
||||
@ -1222,7 +1222,7 @@ QJniObject QJniObject::callStaticObjectMethod(jclass clazz,
|
||||
{
|
||||
QJniEnvironment env;
|
||||
if (clazz) {
|
||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
||||
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||
if (id) {
|
||||
va_list args;
|
||||
va_start(args, signature);
|
||||
@ -1349,12 +1349,12 @@ Q_CORE_EXPORT void QJniObject::setStaticField<jobject>(const char *className,
|
||||
jobject value)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jclass clazz = loadClass(className, env);
|
||||
jclass clazz = loadClass(className, env.jniEnv());
|
||||
|
||||
if (!clazz)
|
||||
return;
|
||||
|
||||
jfieldID id = getCachedFieldID(env, clazz, className, fieldName, signature, true);
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, className, fieldName, signature, true);
|
||||
if (id) {
|
||||
env->SetStaticObjectField(clazz, id, value);
|
||||
env.checkAndClearExceptions();
|
||||
@ -1373,7 +1373,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<jobject>(jclass clazz,
|
||||
jobject value)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jfieldID id = getFieldID(env, clazz, fieldName, signature, true);
|
||||
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, signature, true);
|
||||
|
||||
if (id) {
|
||||
env->SetStaticObjectField(clazz, id, value);
|
||||
@ -1420,7 +1420,7 @@ template <> Q_CORE_EXPORT Type QJniObject::getField<Type>(const char *fieldName)
|
||||
{ \
|
||||
QJniEnvironment env; \
|
||||
Type res = 0; \
|
||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, Signature); \
|
||||
if (id) {\
|
||||
res = env->Get##FieldName##Field(d->m_jobject, id); \
|
||||
if (env.checkAndClearExceptions()) \
|
||||
@ -1432,10 +1432,10 @@ template <> \
|
||||
Q_CORE_EXPORT Type QJniObject::getStaticField<Type>(const char *className, const char *fieldName) \
|
||||
{ \
|
||||
QJniEnvironment env; \
|
||||
jclass clazz = loadClass(className, env); \
|
||||
jclass clazz = loadClass(className, env.jniEnv()); \
|
||||
if (!clazz) \
|
||||
return 0; \
|
||||
jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, \
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, toBinaryEncClassName(className), fieldName, \
|
||||
Signature, true); \
|
||||
if (!id) \
|
||||
return 0; \
|
||||
@ -1449,7 +1449,7 @@ Q_CORE_EXPORT Type QJniObject::getStaticField<Type>(jclass clazz, const char *fi
|
||||
{\
|
||||
QJniEnvironment env;\
|
||||
Type res = 0;\
|
||||
jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\
|
||||
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, Signature, true);\
|
||||
if (id) {\
|
||||
res = env->GetStatic##FieldName##Field(clazz, id);\
|
||||
if (env.checkAndClearExceptions()) \
|
||||
@ -1462,10 +1462,10 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(const char *clas
|
||||
Type value) \
|
||||
{ \
|
||||
QJniEnvironment env; \
|
||||
jclass clazz = loadClass(className, env); \
|
||||
jclass clazz = loadClass(className, env.jniEnv()); \
|
||||
if (!clazz) \
|
||||
return; \
|
||||
jfieldID id = getCachedFieldID(env, clazz, className, fieldName, Signature, true); \
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, className, fieldName, Signature, true); \
|
||||
if (!id) \
|
||||
return; \
|
||||
env->SetStatic##FieldName##Field(clazz, id, value); \
|
||||
@ -1476,7 +1476,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(jclass clazz,\
|
||||
Type value)\
|
||||
{\
|
||||
QJniEnvironment env;\
|
||||
jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\
|
||||
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, Signature, true);\
|
||||
if (id) {\
|
||||
env->SetStatic##FieldName##Field(clazz, id, value);\
|
||||
env.checkAndClearExceptions();\
|
||||
@ -1485,7 +1485,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(jclass clazz,\
|
||||
template <> Q_CORE_EXPORT void QJniObject::setField<Type>(const char *fieldName, Type value) \
|
||||
{ \
|
||||
QJniEnvironment env; \
|
||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, Signature); \
|
||||
if (id) { \
|
||||
env->Set##FieldName##Field(d->m_jobject, id, value); \
|
||||
env.checkAndClearExceptions(); \
|
||||
@ -1521,10 +1521,10 @@ QJniObject QJniObject::getStaticObjectField(const char *className,
|
||||
const char *signature)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jclass clazz = loadClass(className, env);
|
||||
jclass clazz = loadClass(className, env.jniEnv());
|
||||
if (!clazz)
|
||||
return QJniObject();
|
||||
jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName,
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, toBinaryEncClassName(className), fieldName,
|
||||
signature, true);
|
||||
if (!id)
|
||||
return QJniObject();
|
||||
@ -1549,7 +1549,7 @@ QJniObject QJniObject::getStaticObjectField(jclass clazz,
|
||||
const char *signature)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jfieldID id = getFieldID(env, clazz, fieldName, signature, true);
|
||||
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, signature, true);
|
||||
if (!id)
|
||||
return QJniObject();
|
||||
|
||||
@ -1628,7 +1628,7 @@ template <> Q_CORE_EXPORT
|
||||
void QJniObject::setField<jobject>(const char *fieldName, const char *signature, jobject value)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, signature);
|
||||
if (id) {
|
||||
env->SetObjectField(d->m_jobject, id, value);
|
||||
env.checkAndClearExceptions();
|
||||
@ -1641,7 +1641,7 @@ void QJniObject::setField<jobjectArray>(const char *fieldName,
|
||||
jobjectArray value)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, signature);
|
||||
if (id) {
|
||||
env->SetObjectField(d->m_jobject, id, value);
|
||||
env.checkAndClearExceptions();
|
||||
@ -1672,7 +1672,7 @@ void QJniObject::setField<jobjectArray>(const char *fieldName,
|
||||
QJniObject QJniObject::getObjectField(const char *fieldName, const char *signature) const
|
||||
{
|
||||
QJniEnvironment env;
|
||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
|
||||
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, signature);
|
||||
if (!id)
|
||||
return QJniObject();
|
||||
|
||||
@ -1815,10 +1815,10 @@ bool QJniObject::isClassAvailable(const char *className)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
|
||||
if (!env)
|
||||
if (!env.jniEnv())
|
||||
return false;
|
||||
|
||||
return loadClass(className, env);;
|
||||
return loadClass(className, env.jniEnv());;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -864,7 +864,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
|
||||
if (leftWidth == QScFixedFactor)
|
||||
coverage[0] = rightWidth * 255;
|
||||
else
|
||||
coverage[0] = (leftWidth + rightWidth) * 255;
|
||||
coverage[0] = (rightWidth + leftWidth - QScFixedFactor) * 255;
|
||||
x[0] = iLeft;
|
||||
len[0] = 1;
|
||||
} else {
|
||||
|
@ -320,7 +320,7 @@ namespace QtAndroid
|
||||
int createSurface(AndroidSurfaceClient *client, const QRect &geometry, bool onTop, int imageDepth)
|
||||
{
|
||||
QJniEnvironment env;
|
||||
if (!env)
|
||||
if (!env.jniEnv())
|
||||
return -1;
|
||||
|
||||
m_surfacesMutex.lock();
|
||||
@ -383,7 +383,7 @@ namespace QtAndroid
|
||||
return;
|
||||
|
||||
QJniEnvironment env;
|
||||
if (!env)
|
||||
if (!env.jniEnv())
|
||||
return;
|
||||
jint x = 0, y = 0, w = -1, h = -1;
|
||||
if (!geometry.isNull()) {
|
||||
@ -412,7 +412,7 @@ namespace QtAndroid
|
||||
}
|
||||
|
||||
QJniEnvironment env;
|
||||
if (env)
|
||||
if (env.jniEnv())
|
||||
env->CallStaticVoidMethod(m_applicationClass,
|
||||
m_destroySurfaceMethodID,
|
||||
surfaceId);
|
||||
|
@ -155,7 +155,7 @@ void QAndroidPlatformMenu::showPopup(const QWindow *parentWindow, const QRect &t
|
||||
Q_UNUSED(parentWindow);
|
||||
Q_UNUSED(item);
|
||||
setVisible(true);
|
||||
QtAndroidMenu::showContextMenu(this, targetRect, QJniEnvironment());
|
||||
QtAndroidMenu::showContextMenu(this, targetRect, QJniEnvironment().jniEnv());
|
||||
}
|
||||
|
||||
QPlatformMenuItem *QAndroidPlatformMenu::menuItemForTag(quintptr tag) const
|
||||
|
@ -176,7 +176,7 @@ void QAndroidPlatformOpenGLWindow::createEgl(EGLConfig config)
|
||||
{
|
||||
clearEgl();
|
||||
QJniEnvironment env;
|
||||
m_nativeWindow = ANativeWindow_fromSurface(env, m_androidSurfaceObject.object());
|
||||
m_nativeWindow = ANativeWindow_fromSurface(env.jniEnv(), m_androidSurfaceObject.object());
|
||||
m_androidSurfaceObject = QJniObject();
|
||||
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, NULL);
|
||||
m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat());
|
||||
|
@ -26,6 +26,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <QtCore/QJniEnvironment>
|
||||
#include <QtCore/QJniObject>
|
||||
#include <QtTest/QtTest>
|
||||
@ -56,7 +58,7 @@ void tst_QJniEnvironment::jniEnv()
|
||||
JNIEnv *jni = 0;
|
||||
QCOMPARE(javaVM->GetEnv((void**)&jni, JNI_VERSION_1_6), JNI_OK);
|
||||
|
||||
JNIEnv *e = env;
|
||||
JNIEnv *e = env.jniEnv();
|
||||
QVERIFY(e);
|
||||
|
||||
QCOMPARE(env->GetVersion(), JNI_VERSION_1_6);
|
||||
@ -71,11 +73,11 @@ void tst_QJniEnvironment::jniEnv()
|
||||
env->ExceptionClear();
|
||||
|
||||
QVERIFY(env->FindClass("java/lang/Object"));
|
||||
QVERIFY(!QJniEnvironment::checkAndClearExceptions(env));
|
||||
QVERIFY(!QJniEnvironment::checkAndClearExceptions(env.jniEnv()));
|
||||
|
||||
// try to find a nonexistent class
|
||||
QVERIFY(!env->FindClass("this/doesnt/Exist"));
|
||||
QVERIFY(QJniEnvironment::checkAndClearExceptions(env));
|
||||
QVERIFY(QJniEnvironment::checkAndClearExceptions(env.jniEnv()));
|
||||
|
||||
// try to find an existing class with QJniEnvironment
|
||||
QJniEnvironment env;
|
||||
@ -110,6 +112,7 @@ void tst_QJniEnvironment::javaVM()
|
||||
|
||||
static void callbackFromJava(JNIEnv *env, jobject /*thiz*/, jstring value)
|
||||
{
|
||||
Q_UNUSED(env)
|
||||
registerNativesString = QJniObject(value).toString();
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,8 @@ void tst_QMetaType::typeBuiltin_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("typeName");
|
||||
for (int i = 0; i < QMetaType::User; ++i) {
|
||||
const char *name = QMetaType::typeName(i);
|
||||
if (name)
|
||||
QTest::newRow(name) << QByteArray(name);
|
||||
if (QMetaType metaType(i); metaType.isValid())
|
||||
QTest::newRow(metaType.name()) << QByteArray(metaType.name());
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +97,7 @@ void tst_QMetaType::typeBuiltin()
|
||||
const char *nm = typeName.constData();
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i)
|
||||
QMetaType::type(nm);
|
||||
QMetaType::fromName(nm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +112,7 @@ void tst_QMetaType::typeBuiltin_QByteArray()
|
||||
QFETCH(QByteArray, typeName);
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i)
|
||||
QMetaType::type(typeName);
|
||||
QMetaType::fromName(typeName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,9 +120,8 @@ void tst_QMetaType::typeBuiltinNotNormalized_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("typeName");
|
||||
for (int i = 0; i < QMetaType::User; ++i) {
|
||||
const char *name = QMetaType::typeName(i);
|
||||
if (name)
|
||||
QTest::newRow(name) << QByteArray(name).append(" ");
|
||||
if (QMetaType metaType(i); metaType.isValid())
|
||||
QTest::newRow(metaType.name()) << QByteArray(metaType.name()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +131,7 @@ void tst_QMetaType::typeBuiltinNotNormalized()
|
||||
const char *nm = typeName.constData();
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 10000; ++i)
|
||||
QMetaType::type(nm);
|
||||
QMetaType::fromName(nm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +142,7 @@ void tst_QMetaType::typeCustom()
|
||||
qRegisterMetaType<Foo>("Foo");
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 10000; ++i)
|
||||
QMetaType::type("Foo");
|
||||
QMetaType::fromName("Foo");
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,25 +151,25 @@ void tst_QMetaType::typeCustomNotNormalized()
|
||||
qRegisterMetaType<Foo>("Foo");
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 10000; ++i)
|
||||
QMetaType::type("Foo ");
|
||||
QMetaType::fromName("Foo ");
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMetaType::typeNotRegistered()
|
||||
{
|
||||
Q_ASSERT(QMetaType::type("Bar") == 0);
|
||||
Q_ASSERT(!QMetaType::fromName("Bar").isValid());
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 10000; ++i)
|
||||
QMetaType::type("Bar");
|
||||
QMetaType::fromName("Bar");
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMetaType::typeNotRegisteredNotNormalized()
|
||||
{
|
||||
Q_ASSERT(QMetaType::type("Bar") == 0);
|
||||
Q_ASSERT(!QMetaType::fromName("Bar").isValid());
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 10000; ++i)
|
||||
QMetaType::type("Bar ");
|
||||
QMetaType::fromName("Bar ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,9 +177,8 @@ void tst_QMetaType::typeNameBuiltin_data()
|
||||
{
|
||||
QTest::addColumn<int>("type");
|
||||
for (int i = 0; i < QMetaType::User; ++i) {
|
||||
const char *name = QMetaType::typeName(i);
|
||||
if (name)
|
||||
QTest::newRow(name) << i;
|
||||
if (QMetaType metaType(i); metaType.isValid())
|
||||
QTest::newRow(metaType.name()) << i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +187,7 @@ void tst_QMetaType::typeNameBuiltin()
|
||||
QFETCH(int, type);
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 500000; ++i)
|
||||
QMetaType::typeName(type);
|
||||
QMetaType(type).name();
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,17 +196,17 @@ void tst_QMetaType::typeNameCustom()
|
||||
int type = qRegisterMetaType<Foo>("Foo");
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i)
|
||||
QMetaType::typeName(type);
|
||||
QMetaType(type).name();
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMetaType::typeNameNotRegistered()
|
||||
{
|
||||
// We don't care much about this case, but test it anyway.
|
||||
Q_ASSERT(QMetaType::typeName(-1) == 0);
|
||||
Q_ASSERT(QMetaType(-1).name() == nullptr);
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 500000; ++i)
|
||||
QMetaType::typeName(-1);
|
||||
QMetaType(-1).name();
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,7 +235,7 @@ void tst_QMetaType::isRegisteredCustom()
|
||||
|
||||
void tst_QMetaType::isRegisteredNotRegistered()
|
||||
{
|
||||
Q_ASSERT(QMetaType::typeName(-1) == 0);
|
||||
Q_ASSERT(QMetaType(-1).name() == nullptr);
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i)
|
||||
QMetaType::isRegistered(-1);
|
||||
@ -249,7 +246,7 @@ void tst_QMetaType::constructInPlace_data()
|
||||
{
|
||||
QTest::addColumn<int>("typeId");
|
||||
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
|
||||
auto name = QMetaType::typeName(i);
|
||||
auto name = QMetaType(i).name();
|
||||
if (name && i != QMetaType::Void)
|
||||
QTest::newRow(name) << i;
|
||||
}
|
||||
@ -261,14 +258,15 @@ void tst_QMetaType::constructInPlace_data()
|
||||
void tst_QMetaType::constructInPlace()
|
||||
{
|
||||
QFETCH(int, typeId);
|
||||
int size = QMetaType::sizeOf(typeId);
|
||||
const QMetaType metaType(typeId);
|
||||
size_t size = metaType.sizeOf();
|
||||
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
||||
QCOMPARE(QMetaType::construct(typeId, storage, /*copy=*/0), storage);
|
||||
QMetaType::destruct(typeId, storage);
|
||||
QCOMPARE(metaType.construct(storage, /*copy=*/0), storage);
|
||||
metaType.destruct(storage);
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
QMetaType::construct(typeId, storage, /*copy=*/0);
|
||||
QMetaType::destruct(typeId, storage);
|
||||
metaType.construct(storage, /*copy=*/0);
|
||||
metaType.destruct(storage);
|
||||
}
|
||||
}
|
||||
qFreeAligned(storage);
|
||||
@ -282,18 +280,19 @@ void tst_QMetaType::constructInPlaceCopy_data()
|
||||
void tst_QMetaType::constructInPlaceCopy()
|
||||
{
|
||||
QFETCH(int, typeId);
|
||||
int size = QMetaType::sizeOf(typeId);
|
||||
const QMetaType metaType(typeId);
|
||||
size_t size = metaType.sizeOf();
|
||||
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
||||
void *other = QMetaType::create(typeId);
|
||||
QCOMPARE(QMetaType::construct(typeId, storage, other), storage);
|
||||
QMetaType::destruct(typeId, storage);
|
||||
void *other = metaType.create();
|
||||
QCOMPARE(metaType.construct(storage, other), storage);
|
||||
metaType.destruct(storage);
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
QMetaType::construct(typeId, storage, other);
|
||||
QMetaType::destruct(typeId, storage);
|
||||
metaType.construct(storage, other);
|
||||
metaType.destruct(storage);
|
||||
}
|
||||
}
|
||||
QMetaType::destroy(typeId, other);
|
||||
metaType.destroy(other);
|
||||
qFreeAligned(storage);
|
||||
}
|
||||
|
||||
@ -305,19 +304,19 @@ void tst_QMetaType::constructInPlaceCopyStaticLess_data()
|
||||
void tst_QMetaType::constructInPlaceCopyStaticLess()
|
||||
{
|
||||
QFETCH(int, typeId);
|
||||
int size = QMetaType::sizeOf(typeId);
|
||||
const QMetaType metaType(typeId);
|
||||
size_t size = metaType.sizeOf();
|
||||
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
||||
void *other = QMetaType::create(typeId);
|
||||
QCOMPARE(QMetaType::construct(typeId, storage, other), storage);
|
||||
QMetaType::destruct(typeId, storage);
|
||||
void *other = metaType.create();
|
||||
QCOMPARE(metaType.construct(storage, other), storage);
|
||||
metaType.destruct(storage);
|
||||
QBENCHMARK {
|
||||
QMetaType type(typeId);
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
type.construct(storage, other);
|
||||
type.destruct(storage);
|
||||
metaType.construct(storage, other);
|
||||
metaType.destruct(storage);
|
||||
}
|
||||
}
|
||||
QMetaType::destroy(typeId, other);
|
||||
metaType.destroy(other);
|
||||
qFreeAligned(storage);
|
||||
}
|
||||
|
||||
|
@ -337,8 +337,8 @@ void tst_qvariant::createCoreType_data()
|
||||
{
|
||||
QTest::addColumn<int>("typeId");
|
||||
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
|
||||
if (QMetaType::typeName(i)) // QMetaType(27) does not exist
|
||||
QTest::newRow(QMetaType::typeName(i)) << i;
|
||||
if (QMetaType metaType(i); metaType.isValid()) // QMetaType(27) does not exist
|
||||
QTest::newRow(metaType.typeName(i)) << i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,8 @@ void tst_QGuiMetaType::constructableGuiTypes()
|
||||
{
|
||||
QTest::addColumn<int>("typeId");
|
||||
for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) {
|
||||
QMetaType metaType(i);
|
||||
if (metaType.isValid())
|
||||
QTest::newRow(QMetaType::typeName(i)) << i;
|
||||
if (QMetaType metaType(i); metaType.isValid())
|
||||
QTest::newRow(metaType.name()) << i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,8 @@ void tst_QGuiVariant::createGuiType_data()
|
||||
{
|
||||
QTest::addColumn<int>("typeId");
|
||||
for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) {
|
||||
QMetaType metaType(i);
|
||||
if (metaType.isValid())
|
||||
QTest::newRow(QMetaType::typeName(i)) << i;
|
||||
if (QMetaType metaType(i); metaType.isValid())
|
||||
QTest::newRow(metaType.name()) << i;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user