diff options
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qjni.cpp | 15 | ||||
-rw-r--r-- | src/corelib/kernel/qobjectdefs.h | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qobjectdefs_impl.h | 1 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 2290a74c31..097f641d19 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -230,17 +230,18 @@ QJNIEnvironmentPrivate::QJNIEnvironmentPrivate() : jniEnv(0) { JavaVM *vm = QtAndroidPrivate::javaVM(); - if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) == JNI_EDETACHED) { + const jint ret = vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6); + if (ret == JNI_OK) // Already attached + return; + + if (ret == JNI_EDETACHED) { // We need to (re-)attach JavaVMAttachArgs args = { JNI_VERSION_1_6, qJniThreadName, Q_NULLPTR }; if (vm->AttachCurrentThread(&jniEnv, &args) != JNI_OK) return; - } - if (!jniEnv) - return; - - if (!jniEnvTLS->hasLocalData()) - jniEnvTLS->setLocalData(new QJNIEnvironmentPrivateTLS); + if (!jniEnvTLS->hasLocalData()) // If we attached the thread we own it. + jniEnvTLS->setLocalData(new QJNIEnvironmentPrivateTLS); + } } JNIEnv *QJNIEnvironmentPrivate::operator->() diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 33c123be6c..31e8a670e9 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -97,9 +97,9 @@ class QString; #ifndef QT_NO_TRANSLATION // full set of tr functions # define QT_TR_FUNCTIONS \ - static inline QString tr(const char *s, const char *c = 0, int n = -1) \ + static inline QString tr(const char *s, const char *c = Q_NULLPTR, int n = -1) \ { return staticMetaObject.tr(s, c, n); } \ - QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) \ + QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = Q_NULLPTR, int n = -1) \ { return staticMetaObject.tr(s, c, n); } #else // inherit the ones from QObject diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index af69a91e4a..d5574a4dd1 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -36,6 +36,7 @@ #ifndef QOBJECTDEFS_H #error Do not include qobjectdefs_impl.h directly +#include <QtCore/qnamespace.h> #endif #if 0 |