summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-11-26 22:30:27 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-11-26 22:35:48 +0100
commit4a8273a6fc2e741e811cf5dabc9a3c240306cf7f (patch)
tree2148abc88f8543eecdc0b97b2dd92594836af9b2 /src/corelib/global/qglobal.cpp
parent036c5db468164297d213764c59a4b59daa76d90a (diff)
parent1c2be58fecaff1de5f2849192eb712984ebd59bd (diff)
Merge remote-tracking branch 'origin/stable' into dev
For the conflicts in msvc_nmake.cpp the ifdefs are extended since we need to support windows phone in the target branch while it is not there in the current stable branch (as of Qt 5.2). Conflicts: configure qmake/generators/win32/msvc_nmake.cpp src/3rdparty/angle/src/libEGL/Surface.cpp src/angle/src/common/common.pri src/corelib/global/qglobal.h src/corelib/io/qstandardpaths.cpp src/plugins/platforms/qnx/qqnxintegration.cpp src/plugins/platforms/qnx/qqnxscreeneventhandler.h src/plugins/platforms/xcb/qglxintegration.h src/widgets/kernel/win.pri tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp tools/configure/configureapp.cpp Change-Id: I00b579eefebaf61d26ab9b00046d2b5bd5958812
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r--src/corelib/global/qglobal.cpp112
1 files changed, 83 insertions, 29 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 6f74c7de88..f72d27c2e5 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -88,6 +88,14 @@ Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
#endif
+// Statically check assumptions about the environment we're running
+// in. The idea here is to error or warn if otherwise implicit Qt
+// assumptions are not fulfilled on new hardware or compilers
+// (if this list becomes too long, consider factoring into a separate file)
+Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits");
+Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
+
+
/*!
\class QFlag
\inmodule QtCore
@@ -721,10 +729,6 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
A message generated by the qCritical() function.
\value QtFatalMsg
A message generated by the qFatal() function.
- \value QtTraceMsg
- Used by the qCTrace() macro. Trace events are usually passed only
- to dedicated \a QTracer objects, and do not appear in the installed
- message handler.
\value QtSystemMsg
@@ -981,8 +985,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
/*!
\fn QSysInfo::MacVersion QSysInfo::macVersion()
- Returns the version of Mac OS X on which the application is run (Mac OS X
- Only).
+ Returns the version of Darwin (OS X or iOS) on which the application is run.
*/
/*!
@@ -1018,6 +1021,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0)
\value WV_WINDOWS7 Windows 7, Windows Server 2008 R2 (operating system version 6.1)
\value WV_WINDOWS8 Windows 8 (operating system version 6.2)
+ \value WV_WINDOWS8_1 Windows 8.1 (operating system version 6.3), introduced in Qt 5.2
Alternatively, you may use the following macros which correspond directly to the Windows operating system version number:
@@ -1028,6 +1032,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008
\value WV_6_1 Operating system version 6.1, corresponds to Windows 7 and Windows Server 2008 R2
\value WV_6_2 Operating system version 6.2, corresponds to Windows 8
+ \value WV_6_3 Operating system version 6.3, corresponds to Windows 8.1, introduced in Qt 5.2
CE-based versions:
@@ -1050,7 +1055,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
\enum QSysInfo::MacVersion
This enum provides symbolic names for the various versions of the
- OS X operating system. On OS X, the
+ Darwin operating system, covering both OS X and iOS. The
QSysInfo::MacintoshVersion variable gives the version of the
system on which the application is run.
@@ -1078,6 +1083,15 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value MV_MOUNTAINLION Apple codename for MV_10_8
\value MV_MAVERICKS Apple codename for MV_10_9
+ \value MV_IOS iOS (any)
+ \value MV_IOS_4_3 iOS 4.3
+ \value MV_IOS_5_0 iOS 5.0
+ \value MV_IOS_5_1 iOS 5.1
+ \value MV_IOS_6_0 iOS 6.0
+ \value MV_IOS_6_1 iOS 6.1
+ \value MV_IOS_7_0 iOS 7.0
+ \value MV_IOS_7_1 iOS 7.1
+
\sa WinVersion
*/
@@ -1700,13 +1714,15 @@ static const unsigned int qt_one = 1;
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
#endif
-#if defined(Q_OS_MACX)
+#if defined(Q_OS_MAC)
QT_BEGIN_INCLUDE_NAMESPACE
#include "private/qcore_mac_p.h"
#include "qnamespace.h"
QT_END_INCLUDE_NAMESPACE
+#if defined(Q_OS_OSX)
+
Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref)
{
return FSPathMakeRef(reinterpret_cast<const UInt8 *>(file.toUtf8().constData()), fsref, 0);
@@ -1722,17 +1738,17 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) {
return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding()));
}
-#endif // defined(Q_OS_MACX)
-
-#if defined(Q_OS_MAC)
+#endif // defined(Q_OS_OSX)
QSysInfo::MacVersion QSysInfo::macVersion()
{
-#ifdef Q_OS_MACX
+#if defined(Q_OS_OSX)
SInt32 gestalt_version;
if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
}
+#elif defined(Q_OS_IOS)
+ return qt_ios_version(); // qtcore_mac_objc.mm
#endif
return QSysInfo::MV_Unknown;
}
@@ -1744,6 +1760,38 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
QT_END_INCLUDE_NAMESPACE
+#ifndef Q_OS_WINRT
+static inline OSVERSIONINFO winOsVersion()
+{
+ OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}};
+ // GetVersionEx() has been deprecated in Windows 8.1 and will return
+ // only Windows 8 from that version on.
+# if defined(_MSC_VER) && _MSC_VER >= 1800
+# pragma warning( push )
+# pragma warning( disable : 4996 )
+# endif
+ GetVersionEx(&result);
+# if defined(_MSC_VER) && _MSC_VER >= 1800
+# pragma warning( pop )
+# endif
+# ifndef Q_OS_WINCE
+ if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) {
+ // This could be Windows 8.1 or higher. Note that as of Windows 9,
+ // the major version needs to be checked as well.
+ DWORDLONG conditionMask = 0;
+ VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
+ OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result.dwMajorVersion, result.dwMinorVersion,
+ result.dwBuildNumber, result.dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 };
+ for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion)
+ result.dwMinorVersion = checkVersion.dwMinorVersion;
+ }
+# endif // !Q_OS_WINCE
+ return result;
+}
+#endif // !Q_OS_WINRT
+
QSysInfo::WinVersion QSysInfo::windowsVersion()
{
#ifndef VER_PLATFORM_WIN32s
@@ -1766,9 +1814,7 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_WINDOWS8;
#else
winver = QSysInfo::WV_NT;
- OSVERSIONINFO osver;
- osver.dwOSVersionInfoSize = sizeof(osver);
- GetVersionEx(&osver);
+ const OSVERSIONINFO osver = winOsVersion();
#ifdef Q_OS_WINCE
DWORD qt_cever = 0;
qt_cever = osver.dwMajorVersion * 100;
@@ -1814,6 +1860,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_WINDOWS7;
} else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
winver = QSysInfo::WV_WINDOWS8;
+ } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) {
+ winver = QSysInfo::WV_WINDOWS8_1;
} else {
qWarning("Qt: Untested Windows version %d.%d detected!",
int(osver.dwMajorVersion), int(osver.dwMinorVersion));
@@ -2389,9 +2437,14 @@ void qsrand(uint seed)
srand(seed);
}
#elif defined(Q_OS_ANDROID)
- QJNIObjectPrivate random = QJNIObjectPrivate("java/util/Random",
- "(J)V",
- jlong(seed));
+ if (randomTLS->hasLocalData()) {
+ randomTLS->localData().callMethod<void>("setSeed", "(J)V", jlong(seed));
+ return;
+ }
+
+ QJNIObjectPrivate random("java/util/Random",
+ "(J)V",
+ jlong(seed));
if (!random.isValid()) {
srand(seed);
return;
@@ -2444,19 +2497,20 @@ int qrand()
if (!randomStorage)
return rand();
- QJNIObjectPrivate random;
- if (!randomStorage->hasLocalData()) {
- random = QJNIObjectPrivate("java/util/Random",
- "(J)V",
- jlong(1));
- if (!random.isValid())
- return rand();
-
- randomStorage->setLocalData(random);
- } else {
- random = randomStorage->localData();
+ if (randomStorage->hasLocalData()) {
+ return randomStorage->localData().callMethod<jint>("nextInt",
+ "(I)I",
+ RAND_MAX);
}
+ QJNIObjectPrivate random("java/util/Random",
+ "(J)V",
+ jlong(1));
+
+ if (!random.isValid())
+ return rand();
+
+ randomStorage->setLocalData(random);
return random.callMethod<jint>("nextInt", "(I)I", RAND_MAX);
#else
// On Windows srand() and rand() already use Thread-Local-Storage