summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-07-10 13:13:55 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-07-10 13:13:55 +0200
commit776ddcab2c6f06d8d66c645eb34038ffaa60e08e (patch)
treea226f703904c88ed1be6f8fffa381823d12125d1 /src/corelib
parent6d166c88220ee09821b65fb2b711fa77a5312971 (diff)
parentf035786021e9f7b1d9512b22774bc15553caaedb (diff)
Merge "Merge remote-tracking branch 'origin/5.3' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser_main.cpp3
-rw-r--r--src/corelib/global/qflags.h21
-rw-r--r--src/corelib/kernel/qjni.cpp35
3 files changed, 33 insertions, 26 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser_main.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser_main.cpp
index 46b4274301..257a138d0d 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser_main.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser_main.cpp
@@ -59,7 +59,8 @@ int main(int argc, char *argv[])
parser.addOption(showProgressOption);
// A boolean option with multiple names (-f, --force)
- QCommandLineOption forceOption(QStringList() << "f" << "force", "Overwrite existing files.");
+ QCommandLineOption forceOption(QStringList() << "f" << "force",
+ QCoreApplication::translate("main", "Overwrite existing files."));
parser.addOption(forceOption);
// An option with a value
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index d7b673bc1f..097f2760b4 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -57,16 +57,22 @@ class QFlag
{
int i;
public:
-#if !defined(__LP64__) && !defined(Q_QDOC)
+ Q_DECL_CONSTEXPR inline QFlag(int ai) : i(ai) {}
+ Q_DECL_CONSTEXPR inline operator int() const { return i; }
+
+#if !defined(Q_CC_MSVC)
+ // Microsoft Visual Studio has buggy behavior when it comes to
+ // unsigned enums: even if the enum is unsigned, the enum tags are
+ // always signed
+# if !defined(__LP64__) && !defined(Q_QDOC)
Q_DECL_CONSTEXPR inline QFlag(long ai) : i(int(ai)) {}
Q_DECL_CONSTEXPR inline QFlag(ulong ai) : i(int(long(ai))) {}
-#endif
- Q_DECL_CONSTEXPR inline QFlag(int ai) : i(ai) {}
+# endif
Q_DECL_CONSTEXPR inline QFlag(uint ai) : i(int(ai)) {}
Q_DECL_CONSTEXPR inline QFlag(short ai) : i(int(ai)) {}
Q_DECL_CONSTEXPR inline QFlag(ushort ai) : i(int(uint(ai))) {}
- Q_DECL_CONSTEXPR inline operator int() const { return i; }
Q_DECL_CONSTEXPR inline operator uint() const { return uint(i); }
+#endif
};
Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE);
@@ -93,7 +99,11 @@ class QFlags
struct Private;
typedef int (Private::*Zero);
public:
-#ifndef Q_QDOC
+#if defined(Q_CC_MSVC) || defined(Q_QDOC)
+ // see above for MSVC
+ // the definition below is too complex for qdoc
+ typedef int Int;
+#else
typedef typename QtPrivate::if_<
QtPrivate::is_unsigned<Enum>::value,
unsigned int,
@@ -103,7 +113,6 @@ public:
typedef Enum enum_type;
// compiler-generated copy/move ctor/assignment operators are fine!
#ifdef Q_QDOC
- typedef int Int; // the real typedef above is too complex for qdoc
inline QFlags(const QFlags &other);
inline QFlags &operator=(const QFlags &other);
#endif
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 437205bf92..aa9b196e62 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -67,6 +67,19 @@ static QString qt_convertJString(jstring string)
return res;
}
+static inline bool exceptionCheckAndClear(JNIEnv *env)
+{
+ if (Q_UNLIKELY(env->ExceptionCheck())) {
+#ifdef QT_DEBUG
+ env->ExceptionDescribe();
+#endif // QT_DEBUG
+ env->ExceptionClear();
+ return true;
+ }
+
+ return false;
+}
+
typedef QHash<QString, jclass> JClassHash;
Q_GLOBAL_STATIC(JClassHash, cachedClasses)
@@ -85,14 +98,8 @@ static jclass getCachedClass(JNIEnv *env, const char *className)
QJNIObjectPrivate classObject = classLoader.callObjectMethod("loadClass",
"(Ljava/lang/String;)Ljava/lang/Class;",
stringName.object());
- if (env->ExceptionCheck()) {
-#ifdef QT_DEBUG
- env->ExceptionDescribe();
-#endif // QT_DEBUG
- env->ExceptionClear();
- }
- if (classObject.isValid())
+ if (!exceptionCheckAndClear(env) && classObject.isValid())
clazz = static_cast<jclass>(env->NewGlobalRef(classObject.object()));
cachedClasses->insert(key, clazz);
@@ -121,13 +128,8 @@ static jmethodID getCachedMethodID(JNIEnv *env,
else
id = env->GetMethodID(clazz, name, sig);
- if (env->ExceptionCheck()) {
+ if (exceptionCheckAndClear(env))
id = 0;
-#ifdef QT_DEBUG
- env->ExceptionDescribe();
-#endif // QT_DEBUG
- env->ExceptionClear();
- }
cachedMethodID->insert(key, id);
} else {
@@ -154,13 +156,8 @@ static jfieldID getCachedFieldID(JNIEnv *env,
else
id = env->GetFieldID(clazz, name, sig);
- if (env->ExceptionCheck()) {
+ if (exceptionCheckAndClear(env))
id = 0;
-#ifdef QT_DEBUG
- env->ExceptionDescribe();
-#endif // QT_DEBUG
- env->ExceptionClear();
- }
cachedFieldID->insert(key, id);
} else {