Merge integration refs/builds/qtci/dev/1616752022

This commit is contained in:
Qt CI Bot 2021-03-26 13:12:46 +00:00
commit 16eee0d5cc
9 changed files with 67 additions and 58 deletions

View File

@ -128,11 +128,11 @@ QJniEnvironment::QJniEnvironment()
\fn QJniEnvironment::~QJniEnvironment() \fn QJniEnvironment::~QJniEnvironment()
Detaches the current thread from the Java VM and destroys the QJniEnvironment object. Detaches the current thread from the Java VM and destroys the QJniEnvironment object.
This will clear any pending exception by calling exceptionCheckAndClear(). This will clear any pending exception by calling checkAndClearExceptions().
*/ */
QJniEnvironment::~QJniEnvironment() QJniEnvironment::~QJniEnvironment()
{ {
exceptionCheckAndClear(); checkAndClearExceptions();
} }
/*! /*!
@ -229,7 +229,7 @@ bool QJniEnvironment::registerNativeMethods(const char *className, JNINativeMeth
jclass clazz = d->jniEnv->GetObjectClass(classObject.object()); jclass clazz = d->jniEnv->GetObjectClass(classObject.object());
if (d->jniEnv->RegisterNatives(clazz, methods, size) < 0) { if (d->jniEnv->RegisterNatives(clazz, methods, size) < 0) {
exceptionCheckAndClear(); checkAndClearExceptions();
d->jniEnv->DeleteLocalRef(clazz); d->jniEnv->DeleteLocalRef(clazz);
return false; return false;
} }
@ -248,7 +248,7 @@ bool QJniEnvironment::registerNativeMethods(const char *className, JNINativeMeth
*/ */
/*! /*!
\fn QJniEnvironment::exceptionCheckAndClear(OutputMode outputMode = OutputMode::Verbose) \fn QJniEnvironment::checkAndClearExceptions(OutputMode outputMode = OutputMode::Verbose)
Cleans any pending exceptions either silently or reporting stack backtrace, Cleans any pending exceptions either silently or reporting stack backtrace,
depending on the \a outputMode. depending on the \a outputMode.
@ -260,7 +260,7 @@ bool QJniEnvironment::registerNativeMethods(const char *className, JNINativeMeth
\return \c true when a pending exception was cleared. \return \c true when a pending exception was cleared.
*/ */
bool QJniEnvironment::exceptionCheckAndClear(QJniEnvironment::OutputMode outputMode) bool QJniEnvironment::checkAndClearExceptions(QJniEnvironment::OutputMode outputMode)
{ {
if (Q_UNLIKELY(d->jniEnv->ExceptionCheck())) { if (Q_UNLIKELY(d->jniEnv->ExceptionCheck())) {
if (outputMode != OutputMode::Silent) if (outputMode != OutputMode::Silent)
@ -274,7 +274,7 @@ bool QJniEnvironment::exceptionCheckAndClear(QJniEnvironment::OutputMode outputM
} }
/*! /*!
\fn QJniEnvironment::exceptionCheckAndClear(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose) \fn QJniEnvironment::checkAndClearExceptions(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose)
Cleans any pending exceptions for \a env, either silently or reporting Cleans any pending exceptions for \a env, either silently or reporting
stack backtrace, depending on the \a outputMode. This is useful when you stack backtrace, depending on the \a outputMode. This is useful when you
@ -287,7 +287,7 @@ bool QJniEnvironment::exceptionCheckAndClear(QJniEnvironment::OutputMode outputM
\return \c true when a pending exception was cleared. \return \c true when a pending exception was cleared.
*/ */
bool QJniEnvironment::exceptionCheckAndClear(JNIEnv *env, QJniEnvironment::OutputMode outputMode) bool QJniEnvironment::checkAndClearExceptions(JNIEnv *env, QJniEnvironment::OutputMode outputMode)
{ {
if (Q_UNLIKELY(env->ExceptionCheck())) { if (Q_UNLIKELY(env->ExceptionCheck())) {
if (outputMode != OutputMode::Silent) if (outputMode != OutputMode::Silent)

View File

@ -71,8 +71,8 @@ public:
Verbose Verbose
}; };
bool exceptionCheckAndClear(OutputMode outputMode = OutputMode::Verbose); bool checkAndClearExceptions(OutputMode outputMode = OutputMode::Verbose);
static bool exceptionCheckAndClear(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose); static bool checkAndClearExceptions(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose);
private: private:

View File

@ -291,11 +291,11 @@ void QtAndroidPrivate::handleResume()
static void setAndroidSdkVersion(JNIEnv *env) static void setAndroidSdkVersion(JNIEnv *env)
{ {
jclass androidVersionClass = env->FindClass("android/os/Build$VERSION"); jclass androidVersionClass = env->FindClass("android/os/Build$VERSION");
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return; return;
jfieldID androidSDKFieldID = env->GetStaticFieldID(androidVersionClass, "SDK_INT", "I"); jfieldID androidSDKFieldID = env->GetStaticFieldID(androidVersionClass, "SDK_INT", "I");
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return; return;
g_androidSdkVersion = env->GetStaticIntField(androidVersionClass, androidSDKFieldID); g_androidSdkVersion = env->GetStaticIntField(androidVersionClass, androidSDKFieldID);
@ -331,42 +331,42 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
{ {
jclass jQtNative = env->FindClass("org/qtproject/qt/android/QtNative"); jclass jQtNative = env->FindClass("org/qtproject/qt/android/QtNative");
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
jmethodID activityMethodID = env->GetStaticMethodID(jQtNative, jmethodID activityMethodID = env->GetStaticMethodID(jQtNative,
"activity", "activity",
"()Landroid/app/Activity;"); "()Landroid/app/Activity;");
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
jobject activity = env->CallStaticObjectMethod(jQtNative, activityMethodID); jobject activity = env->CallStaticObjectMethod(jQtNative, activityMethodID);
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
jmethodID serviceMethodID = env->GetStaticMethodID(jQtNative, jmethodID serviceMethodID = env->GetStaticMethodID(jQtNative,
"service", "service",
"()Landroid/app/Service;"); "()Landroid/app/Service;");
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
jobject service = env->CallStaticObjectMethod(jQtNative, serviceMethodID); jobject service = env->CallStaticObjectMethod(jQtNative, serviceMethodID);
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
jmethodID classLoaderMethodID = env->GetStaticMethodID(jQtNative, jmethodID classLoaderMethodID = env->GetStaticMethodID(jQtNative,
"classLoader", "classLoader",
"()Ljava/lang/ClassLoader;"); "()Ljava/lang/ClassLoader;");
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
jobject classLoader = env->CallStaticObjectMethod(jQtNative, classLoaderMethodID); jobject classLoader = env->CallStaticObjectMethod(jQtNative, classLoaderMethodID);
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
setAndroidSdkVersion(env); setAndroidSdkVersion(env);
@ -394,7 +394,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
const bool regOk = (env->RegisterNatives(jQtNative, methods, sizeof(methods) / sizeof(methods[0])) == JNI_OK); const bool regOk = (env->RegisterNatives(jQtNative, methods, sizeof(methods) / sizeof(methods[0])) == JNI_OK);
if (!regOk && QJniEnvironment::exceptionCheckAndClear(env)) if (!regOk && QJniEnvironment::checkAndClearExceptions(env))
return JNI_ERR; return JNI_ERR;
g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative, g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative,
@ -512,7 +512,7 @@ void QtAndroidPrivate::requestPermissions(JNIEnv *env,
QJniEnvironment env; QJniEnvironment env;
jclass clazz = env->FindClass("java/lang/String"); jclass clazz = env->FindClass("java/lang/String");
if (env.exceptionCheckAndClear()) if (env.checkAndClearExceptions())
return; return;
auto array = env->NewObjectArray(permissions.size(), clazz, nullptr); auto array = env->NewObjectArray(permissions.size(), clazz, nullptr);

View File

@ -132,7 +132,7 @@ QT_BEGIN_NAMESPACE
\note The user must handle exceptions manually when doing JNI calls using \c JNIEnv directly. \note The user must handle exceptions manually when doing JNI calls using \c JNIEnv directly.
It is unsafe to make other JNI calls when exceptions are pending. For more information, see It is unsafe to make other JNI calls when exceptions are pending. For more information, see
QJniEnvironment::exceptionCheckAndClear(). QJniEnvironment::checkAndClearExceptions().
\section1 Java Native Methods \section1 Java Native Methods
@ -346,7 +346,7 @@ inline static jclass loadClass(const QByteArray &className, JNIEnv *env, bool bi
"(Ljava/lang/String;)Ljava/lang/Class;", "(Ljava/lang/String;)Ljava/lang/Class;",
stringName.object()); stringName.object());
if (!QJniEnvironment::exceptionCheckAndClear(env) && classObject.isValid()) if (!QJniEnvironment::checkAndClearExceptions(env) && classObject.isValid())
clazz = static_cast<jclass>(env->NewGlobalRef(classObject.object())); clazz = static_cast<jclass>(env->NewGlobalRef(classObject.object()));
cachedClasses->insert(key, clazz); cachedClasses->insert(key, clazz);
@ -366,7 +366,7 @@ static inline jmethodID getMethodID(JNIEnv *env,
jmethodID id = isStatic ? env->GetStaticMethodID(clazz, name, signature) jmethodID id = isStatic ? env->GetStaticMethodID(clazz, name, signature)
: env->GetMethodID(clazz, name, signature); : env->GetMethodID(clazz, name, signature);
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return nullptr; return nullptr;
return id; return id;
@ -420,7 +420,7 @@ static inline jfieldID getFieldID(JNIEnv *env,
jfieldID id = isStatic ? env->GetStaticFieldID(clazz, name, signature) jfieldID id = isStatic ? env->GetStaticFieldID(clazz, name, signature)
: env->GetFieldID(clazz, name, signature); : env->GetFieldID(clazz, name, signature);
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return nullptr; return nullptr;
return id; return id;
@ -479,7 +479,7 @@ jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
return it.value(); return it.value();
jclass fclazz = env->FindClass(className); jclass fclazz = env->FindClass(className);
if (!QJniEnvironment::exceptionCheckAndClear(env)) { if (!QJniEnvironment::checkAndClearExceptions(env)) {
clazz = static_cast<jclass>(env->NewGlobalRef(fclazz)); clazz = static_cast<jclass>(env->NewGlobalRef(fclazz));
env->DeleteLocalRef(fclazz); env->DeleteLocalRef(fclazz);
} }
@ -726,7 +726,7 @@ inline static QJniObject getCleanJniObject(jobject obj)
return QJniObject(); return QJniObject();
QJniEnvironment env; QJniEnvironment env;
if (env.exceptionCheckAndClear()) { if (env.checkAndClearExceptions()) {
env->DeleteLocalRef(obj); env->DeleteLocalRef(obj);
return QJniObject(); return QJniObject();
} }
@ -775,7 +775,7 @@ QJniObject QJniObject::callObjectMethodV(const char *methodName,
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature); jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
if (id) { if (id) {
res = env->CallObjectMethodV(d->m_jobject, id, args); res = env->CallObjectMethodV(d->m_jobject, id, args);
if (env.exceptionCheckAndClear()) { if (env.checkAndClearExceptions()) {
env->DeleteLocalRef(res); env->DeleteLocalRef(res);
res = nullptr; res = nullptr;
} }
@ -799,7 +799,7 @@ QJniObject QJniObject::callStaticObjectMethodV(const char *className,
methodName, signature, true); methodName, signature, true);
if (id) { if (id) {
res = env->CallStaticObjectMethodV(clazz, id, args); res = env->CallStaticObjectMethodV(clazz, id, args);
if (env.exceptionCheckAndClear()) { if (env.checkAndClearExceptions()) {
env->DeleteLocalRef(res); env->DeleteLocalRef(res);
res = nullptr; res = nullptr;
} }
@ -846,7 +846,7 @@ Q_CORE_EXPORT void QJniObject::callMethod<void>(const char *methodName, const ch
va_start(args, signature); va_start(args, signature);
env->CallVoidMethodV(d->m_jobject, id, args); env->CallVoidMethodV(d->m_jobject, id, args);
va_end(args); va_end(args);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
@ -894,7 +894,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethod<void>(const char *className,
va_start(args, signature); va_start(args, signature);
env->CallStaticVoidMethodV(clazz, id, args); env->CallStaticVoidMethodV(clazz, id, args);
va_end(args); va_end(args);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
} }
@ -942,7 +942,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethod<void>(jclass clazz,
va_start(args, signature); va_start(args, signature);
env->CallStaticVoidMethodV(clazz, id, args); env->CallStaticVoidMethodV(clazz, id, args);
va_end(args); va_end(args);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
} }
@ -961,7 +961,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethodV<void>(const char *className,
signature, true); signature, true);
if (id) { if (id) {
env->CallStaticVoidMethodV(clazz, id, args); env->CallStaticVoidMethodV(clazz, id, args);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
} }
@ -976,7 +976,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethodV<void>(jclass clazz,
jmethodID id = getMethodID(env, clazz, methodName, signature, true); jmethodID id = getMethodID(env, clazz, methodName, signature, true);
if (id) { if (id) {
env->CallStaticVoidMethodV(clazz, id, args); env->CallStaticVoidMethodV(clazz, id, args);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
@ -1005,7 +1005,7 @@ Q_CORE_EXPORT void QJniObject::callMethodV<void>(const char *methodName, const c
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature); jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
if (id) { if (id) {
env->CallVoidMethodV(d->m_jobject, id, args); env->CallVoidMethodV(d->m_jobject, id, args);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
@ -1021,7 +1021,7 @@ template <> Q_CORE_EXPORT Type QJniObject::callMethod<Type>(const char *methodNa
va_start(args, signature); \ va_start(args, signature); \
res = env->Call##MethodName##MethodV(d->m_jobject, id, args); \ res = env->Call##MethodName##MethodV(d->m_jobject, id, args); \
va_end(args); \ va_end(args); \
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
} \ } \
return res; \ return res; \
@ -1047,7 +1047,7 @@ template <> Q_CORE_EXPORT Type QJniObject::callStaticMethod<Type>(const char *cl
va_start(args, signature); \ va_start(args, signature); \
res = env->CallStatic##MethodName##MethodV(clazz, id, args); \ res = env->CallStatic##MethodName##MethodV(clazz, id, args); \
va_end(args); \ va_end(args); \
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
} \ } \
} \ } \
@ -1073,7 +1073,7 @@ template <> Q_CORE_EXPORT Type QJniObject::callStaticMethod<Type>(jclass clazz,
va_start(args, signature); \ va_start(args, signature); \
res = env->CallStatic##MethodName##MethodV(clazz, id, args); \ res = env->CallStatic##MethodName##MethodV(clazz, id, args); \
va_end(args); \ va_end(args); \
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
} \ } \
} \ } \
@ -1093,7 +1093,7 @@ Q_CORE_EXPORT Type QJniObject::callMethodV<Type>(const char *methodName, const c
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);\ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);\
if (id) {\ if (id) {\
res = env->Call##MethodName##MethodV(d->m_jobject, id, args);\ res = env->Call##MethodName##MethodV(d->m_jobject, id, args);\
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
}\ }\
return res;\ return res;\
@ -1112,7 +1112,7 @@ Q_CORE_EXPORT Type QJniObject::callStaticMethodV<Type>(const char *className,\
signature, true);\ signature, true);\
if (id) {\ if (id) {\
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\ res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
}\ }\
}\ }\
@ -1129,7 +1129,7 @@ Q_CORE_EXPORT Type QJniObject::callStaticMethodV<Type>(jclass clazz,\
jmethodID id = getMethodID(env, clazz, methodName, signature, true);\ jmethodID id = getMethodID(env, clazz, methodName, signature, true);\
if (id) {\ if (id) {\
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\ res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
}\ }\
return res;\ return res;\
@ -1357,7 +1357,7 @@ Q_CORE_EXPORT void QJniObject::setStaticField<jobject>(const char *className,
jfieldID id = getCachedFieldID(env, clazz, className, fieldName, signature, true); jfieldID id = getCachedFieldID(env, clazz, className, fieldName, signature, true);
if (id) { if (id) {
env->SetStaticObjectField(clazz, id, value); env->SetStaticObjectField(clazz, id, value);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
@ -1377,7 +1377,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<jobject>(jclass clazz,
if (id) { if (id) {
env->SetStaticObjectField(clazz, id, value); env->SetStaticObjectField(clazz, id, value);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
@ -1423,7 +1423,7 @@ template <> Q_CORE_EXPORT Type QJniObject::getField<Type>(const char *fieldName)
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \
if (id) {\ if (id) {\
res = env->Get##FieldName##Field(d->m_jobject, id); \ res = env->Get##FieldName##Field(d->m_jobject, id); \
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
} \ } \
return res;\ return res;\
@ -1440,7 +1440,7 @@ Q_CORE_EXPORT Type QJniObject::getStaticField<Type>(const char *className, const
if (!id) \ if (!id) \
return 0; \ return 0; \
Type res = env->GetStatic##FieldName##Field(clazz, id); \ Type res = env->GetStatic##FieldName##Field(clazz, id); \
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
return res;\ return res;\
} \ } \
@ -1452,7 +1452,7 @@ Q_CORE_EXPORT Type QJniObject::getStaticField<Type>(jclass clazz, const char *fi
jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\ jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\
if (id) {\ if (id) {\
res = env->GetStatic##FieldName##Field(clazz, id);\ res = env->GetStatic##FieldName##Field(clazz, id);\
if (env.exceptionCheckAndClear()) \ if (env.checkAndClearExceptions()) \
res = 0; \ res = 0; \
}\ }\
return res;\ return res;\
@ -1469,7 +1469,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(const char *clas
if (!id) \ if (!id) \
return; \ return; \
env->SetStatic##FieldName##Field(clazz, id, value); \ env->SetStatic##FieldName##Field(clazz, id, value); \
env.exceptionCheckAndClear(); \ env.checkAndClearExceptions(); \
}\ }\
template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(jclass clazz,\ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(jclass clazz,\
const char *fieldName,\ const char *fieldName,\
@ -1479,7 +1479,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(jclass clazz,\
jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\ jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\
if (id) {\ if (id) {\
env->SetStatic##FieldName##Field(clazz, id, value);\ env->SetStatic##FieldName##Field(clazz, id, value);\
env.exceptionCheckAndClear();\ env.checkAndClearExceptions();\
}\ }\
}\ }\
template <> Q_CORE_EXPORT void QJniObject::setField<Type>(const char *fieldName, Type value) \ template <> Q_CORE_EXPORT void QJniObject::setField<Type>(const char *fieldName, Type value) \
@ -1488,7 +1488,7 @@ template <> Q_CORE_EXPORT void QJniObject::setField<Type>(const char *fieldName,
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \
if (id) { \ if (id) { \
env->Set##FieldName##Field(d->m_jobject, id, value); \ env->Set##FieldName##Field(d->m_jobject, id, value); \
env.exceptionCheckAndClear(); \ env.checkAndClearExceptions(); \
} \ } \
} \ } \
@ -1631,7 +1631,7 @@ void QJniObject::setField<jobject>(const char *fieldName, const char *signature,
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature); jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
if (id) { if (id) {
env->SetObjectField(d->m_jobject, id, value); env->SetObjectField(d->m_jobject, id, value);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }
@ -1644,7 +1644,7 @@ void QJniObject::setField<jobjectArray>(const char *fieldName,
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature); jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
if (id) { if (id) {
env->SetObjectField(d->m_jobject, id, value); env->SetObjectField(d->m_jobject, id, value);
env.exceptionCheckAndClear(); env.checkAndClearExceptions();
} }
} }

View File

@ -1341,7 +1341,7 @@ void QPainterPath::addRegion(const QRegion &region)
*/ */
Qt::FillRule QPainterPath::fillRule() const Qt::FillRule QPainterPath::fillRule() const
{ {
return isEmpty() ? Qt::OddEvenFill : d_func()->fillRule; return !d_func() ? Qt::OddEvenFill : d_func()->fillRule;
} }
/*! /*!

View File

@ -292,7 +292,6 @@ inline void QPainterPathPrivate::clear()
elements.clear(); elements.clear();
cStart = 0; cStart = 0;
fillRule = Qt::OddEvenFill;
bounds = {}; bounds = {};
controlBounds = {}; controlBounds = {};

View File

@ -135,12 +135,12 @@ Java_org_qtproject_qt_android_ExtractStyle_extractChunkInfo20(JNIEnv *env, jobje
env->GetByteArrayRegion(chunkObj, 0, chunkSize, env->GetByteArrayRegion(chunkObj, 0, chunkSize,
reinterpret_cast<jbyte*>(storage)); reinterpret_cast<jbyte*>(storage));
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
return 0; return 0;
jintArray res = Java_org_qtproject_qt_android_ExtractStyle_extractNativeChunkInfo20(env, obj, jintArray res = Java_org_qtproject_qt_android_ExtractStyle_extractNativeChunkInfo20(env, obj,
long(storage)); long(storage));
if (QJniEnvironment::exceptionCheckAndClear(env)) if (QJniEnvironment::checkAndClearExceptions(env))
res = nullptr; res = nullptr;
return res; return res;

View File

@ -71,11 +71,11 @@ void tst_QJniEnvironment::jniEnv()
env->ExceptionClear(); env->ExceptionClear();
QVERIFY(env->FindClass("java/lang/Object")); QVERIFY(env->FindClass("java/lang/Object"));
QVERIFY(!QJniEnvironment::exceptionCheckAndClear(env)); QVERIFY(!QJniEnvironment::checkAndClearExceptions(env));
// try to find a nonexistent class // try to find a nonexistent class
QVERIFY(!env->FindClass("this/doesnt/Exist")); QVERIFY(!env->FindClass("this/doesnt/Exist"));
QVERIFY(QJniEnvironment::exceptionCheckAndClear(env)); QVERIFY(QJniEnvironment::checkAndClearExceptions(env));
// try to find an existing class with QJniEnvironment // try to find an existing class with QJniEnvironment
QJniEnvironment env; QJniEnvironment env;
@ -86,7 +86,7 @@ void tst_QJniEnvironment::jniEnv()
// clear exception with member function // clear exception with member function
QVERIFY(!env->FindClass("this/doesnt/Exist")); QVERIFY(!env->FindClass("this/doesnt/Exist"));
QVERIFY(env.exceptionCheckAndClear()); QVERIFY(env.checkAndClearExceptions());
} }
// The env does not detach automatically, even if it goes out of scope. The only way it can // The env does not detach automatically, even if it goes out of scope. The only way it can

View File

@ -173,8 +173,18 @@ void tst_QPainterPath::clear()
p1.setFillRule(Qt::WindingFill); p1.setFillRule(Qt::WindingFill);
QVERIFY(p1 != p3); QVERIFY(p1 != p3);
p1.clear(); p1.clear();
QCOMPARE(p1.fillRule(), Qt::OddEvenFill); QVERIFY(p1 != p3);
p1.setFillRule(Qt::OddEvenFill);
QCOMPARE(p1, p2); QCOMPARE(p1, p2);
QPainterPath p4;
QCOMPARE(p4.fillRule(), Qt::OddEvenFill);
p4.setFillRule(Qt::WindingFill);
QCOMPARE(p4.fillRule(), Qt::WindingFill);
p4.clear();
QCOMPARE(p4.fillRule(), Qt::WindingFill);
p4 = QPainterPath();
QCOMPARE(p4.fillRule(), Qt::OddEvenFill);
} }
void tst_QPainterPath::reserveAndCapacity() void tst_QPainterPath::reserveAndCapacity()