diff options
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/global.pri | 2 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 106 | ||||
-rw-r--r-- | src/corelib/global/qendian.h | 254 | ||||
-rw-r--r-- | src/corelib/global/qflags.h | 73 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 191 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 73 | ||||
-rw-r--r-- | src/corelib/global/qhooks.cpp | 2 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 110 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.h | 10 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 212 | ||||
-rw-r--r-- | src/corelib/global/qlogging.h | 18 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.h | 150 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 22 | ||||
-rw-r--r-- | src/corelib/global/qsysinfo.h | 20 | ||||
-rw-r--r-- | src/corelib/global/qsystemdetection.h | 3 | ||||
-rw-r--r-- | src/corelib/global/qtypeinfo.h | 13 |
16 files changed, 802 insertions, 457 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index e0dd9e4f36..bc11c77d88 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -38,7 +38,7 @@ PRECOMPILED_HEADER = global/qt_pch.h # qlogging.cpp uses backtrace(3), which is in a separate library on the BSDs. LIBS_PRIVATE += $$QMAKE_LIBS_EXECINFO -linux*:!cross_compile:!static:!*-armcc* { +if(linux*|hurd*):!cross_compile:!static:!*-armcc* { QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate prog=$$quote(if (/program interpreter: (.*)]/) { print $1; }) DEFINES += ELF_INTERPRETER=\\\"$$system(readelf -l /bin/ls | perl -n -e \'$$prog\')\\\" diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 7effb24130..2881a0fcbd 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Copyright (C) 2012 Intel Corporation +** Copyright (C) 2014 Intel Corporation ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -75,7 +75,6 @@ # if defined(__SC__) && __SC__ < 0x750 # error "Compiler not supported" # endif -# define Q_NO_USING_KEYWORD #elif defined(_MSC_VER) # define Q_CC_MSVC (_MSC_VER) @@ -113,7 +112,6 @@ # if __BORLANDC__ < 0x502 # error "Compiler not supported" # endif -# define Q_NO_USING_KEYWORD #elif defined(__WATCOMC__) # define Q_CC_WAT @@ -138,7 +136,6 @@ #elif defined(__GNUC__) # define Q_CC_GNU (__GNUC__ * 100 + __GNUC_MINOR__) -# define Q_C_CALLBACKS # if defined(__MINGW32__) # define Q_CC_MINGW # endif @@ -282,7 +279,6 @@ # error "Compiler not supported" # endif /* Spurious (?) error messages observed on Compaq C++ V6.5-014. */ -# define Q_NO_USING_KEYWORD /* Apply to all versions prior to Compaq C++ V6.0-000 - observed on DEC C++ V5.5-004. */ # if __DECCXX_VER < 60060000 @@ -319,7 +315,6 @@ /* The Comeau compiler is based on EDG and does define __EDG__ */ # if defined(__COMO__) # define Q_CC_COMEAU -# define Q_C_CALLBACKS /* The `using' keyword was introduced to avoid KAI C++ warnings but it's now causing KAI C++ errors instead. The standard is @@ -327,7 +322,6 @@ compiler is using its own set of rules. Forget it. */ # elif defined(__KCC) # define Q_CC_KAI -# define Q_NO_USING_KEYWORD /* Using the `using' keyword avoids Intel C++ for Linux warnings */ # elif defined(__INTEL_COMPILER) @@ -350,23 +344,19 @@ # if !defined(__SCO_VERSION__) || (__SCO_VERSION__ < 302200010) # define Q_OUTOFLINE_TEMPLATE inline # endif -# define Q_NO_USING_KEYWORD /* ### check "using" status */ /* Never tested! */ # elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER) # define Q_CC_OC -# define Q_NO_USING_KEYWORD /* CDS++ defines __EDG__ although this is not documented in the Reliant documentation. It also follows conventions like _BOOL and this documented */ # elif defined(sinix) # define Q_CC_CDS -# define Q_NO_USING_KEYWORD /* The MIPSpro compiler defines __EDG */ # elif defined(__sgi) # define Q_CC_MIPS -# define Q_NO_USING_KEYWORD /* ### check "using" status */ # define Q_NO_TEMPLATE_FRIENDS # if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 740) # define Q_OUTOFLINE_TEMPLATE inline @@ -408,10 +398,6 @@ # if !defined(_BOOL) # error "Compiler not supported" # endif -# if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4) -# define Q_NO_USING_KEYWORD -# endif -# define Q_C_CALLBACKS /* 4.2 compiler or older */ # else # error "Compiler not supported" @@ -449,7 +435,6 @@ # else # error "Compiler not supported" # endif -# define Q_NO_USING_KEYWORD /* ### check "using" status */ #else # error "Qt has not been tested with this compiler - see http://www.qt-project.org/" @@ -515,7 +500,7 @@ // at least since 13.1, but I can't test further back # define Q_COMPILER_BINARY_LITERALS # endif -# if __cplusplus >= 201103L +# if __cplusplus >= 201103L || defined(__INTEL_CXX11_MODE__) # if __INTEL_COMPILER >= 1200 # define Q_COMPILER_AUTO_TYPE # define Q_COMPILER_CLASS_ENUM @@ -533,6 +518,9 @@ # define Q_COMPILER_AUTO_FUNCTION # define Q_COMPILER_NULLPTR # define Q_COMPILER_TEMPLATE_ALIAS +# ifndef _CHAR16T // MSVC headers +# define Q_COMPILER_UNICODE_STRINGS +# endif # define Q_COMPILER_VARIADIC_TEMPLATES # endif # if __INTEL_COMPILER >= 1300 @@ -879,7 +867,24 @@ # if _MSC_FULL_VER >= 180030324 // VC 12 SP 2 RC # define Q_COMPILER_INITIALIZER_LISTS # endif /* VC 12 SP 2 RC */ - +# if _MSC_VER >= 1900 + /* C++11 features in VC14 = VC2015 */ +# define Q_COMPILER_ALIGNAS +# define Q_COMPILER_ALIGNOF +// Partial support, insufficient for Qt +//# define Q_COMPILER_CONSTEXPR +# define Q_COMPILER_INHERITING_CONSTRUCTORS +# define Q_COMPILER_NOEXCEPT +# define Q_COMPILER_RANGE_FOR +# define Q_COMPILER_REF_QUALIFIERS +# define Q_COMPILER_THREAD_LOCAL +# define Q_COMPILER_THREADSAFE_STATICS +# define Q_COMPILER_UDL +# define Q_COMPILER_UNICODE_STRINGS +// Uniform initialization is not working yet -- build errors with QUuid +//# define Q_COMPILER_UNIFORM_INIT +# define Q_COMPILER_UNRESTRICTED_UNIONS +# endif # endif /* __cplusplus */ #endif /* Q_CC_MSVC */ @@ -949,12 +954,21 @@ # define Q_COMPILER_DEFAULT_DELETE_MEMBERS #endif -#ifdef Q_COMPILER_CONSTEXPR +#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304 +# define Q_DECL_CONSTEXPR constexpr +# define Q_DECL_RELAXED_CONSTEXPR constexpr +# define Q_CONSTEXPR constexpr +# define Q_RELAXED_CONSTEXPR constexpr +#elif defined Q_COMPILER_CONSTEXPR # define Q_DECL_CONSTEXPR constexpr +# define Q_DECL_RELAXED_CONSTEXPR # define Q_CONSTEXPR constexpr +# define Q_RELAXED_CONSTEXPR const #else # define Q_DECL_CONSTEXPR +# define Q_DECL_RELAXED_CONSTEXPR # define Q_CONSTEXPR const +# define Q_RELAXED_CONSTEXPR const #endif #ifdef Q_COMPILER_EXPLICIT_OVERRIDES @@ -1057,6 +1071,60 @@ #endif /* + * Warning/diagnostic handling + */ + +#define QT_DO_PRAGMA(text) _Pragma(#text) +#if defined(Q_CC_INTEL) && defined(Q_CC_MSVC) +/* icl.exe: Intel compiler on Windows */ +# undef QT_DO_PRAGMA /* not needed */ +# define QT_WARNING_PUSH __pragma(warning(push)) +# define QT_WARNING_POP __pragma(warning(pop)) +# define QT_WARNING_DISABLE_MSVC(number) +# define QT_WARNING_DISABLE_INTEL(number) __pragma(warning(disable: number)) +# define QT_WARNING_DISABLE_CLANG(text) +# define QT_WARNING_DISABLE_GCC(text) +#elif defined(Q_CC_INTEL) +/* icc: Intel compiler on Linux or OS X */ +# define QT_WARNING_PUSH QT_DO_PRAGMA(warning(push)) +# define QT_WARNING_POP QT_DO_PRAGMA(warning(pop)) +# define QT_WARNING_DISABLE_INTEL(number) QT_DO_PRAGMA(warning(disable: number)) +# define QT_WARNING_DISABLE_MSVC(number) +# define QT_WARNING_DISABLE_CLANG(text) +# define QT_WARNING_DISABLE_GCC(text) +#elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 +# undef QT_DO_PRAGMA /* not needed */ +# define QT_WARNING_PUSH __pragma(warning(push)) +# define QT_WARNING_POP __pragma(warning(pop)) +# define QT_WARNING_DISABLE_MSVC(number) __pragma(warning(disable: number)) +# define QT_WARNING_DISABLE_INTEL(number) +# define QT_WARNING_DISABLE_CLANG(text) +# define QT_WARNING_DISABLE_GCC(text) +#elif defined(Q_CC_CLANG) +# define QT_WARNING_PUSH QT_DO_PRAGMA(clang diagnostic push) +# define QT_WARNING_POP QT_DO_PRAGMA(clang diagnostic pop) +# define QT_WARNING_DISABLE_CLANG(text) QT_DO_PRAGMA(clang diagnostic ignored text) +# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text) // GCC directives work in Clang too +# define QT_WARNING_DISABLE_INTEL(number) +# define QT_WARNING_DISABLE_MSVC(number) +#elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 405) +# define QT_WARNING_PUSH QT_DO_PRAGMA(GCC diagnostic push) +# define QT_WARNING_POP QT_DO_PRAGMA(GCC diagnostic pop) +# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text) +# define QT_WARNING_DISABLE_CLANG(text) +# define QT_WARNING_DISABLE_INTEL(number) +# define QT_WARNING_DISABLE_MSVC(number) +#else // All other compilers, GCC < 4.6 and MSVC < 2008 +# define QT_WARNING_DISABLE_GCC(text) +# define QT_WARNING_PUSH +# define QT_WARNING_POP +# define QT_WARNING_DISABLE_INTEL(number) +# define QT_WARNING_DISABLE_MSVC(number) +# define QT_WARNING_DISABLE_CLANG(text) +# define QT_WARNING_DISABLE_GCC(text) +#endif + +/* Proper for-scoping in MIPSpro CC */ #ifndef QT_NO_KEYWORDS diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 0e383c18d2..957ba2ad63 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -63,7 +63,7 @@ template <typename T> inline void qbswap(const T src, uchar *dest) } // Used to implement a type-safe and alignment-safe copy operation -// If you want to avoid the memcopy, you must write specializations for this function +// If you want to avoid the memcpy, you must write specializations for these functions template <typename T> inline void qToUnaligned(const T src, uchar *dest) { // Using sizeof(T) inside memcpy function produces internal compiler error with @@ -71,199 +71,14 @@ template <typename T> inline void qToUnaligned(const T src, uchar *dest) const size_t size = sizeof(T); memcpy(dest, &src, size); } - -/* T qFromLittleEndian(const uchar *src) - * This function will read a little-endian encoded value from \a src - * and return the value in host-endian encoding. - * There is no requirement that \a src must be aligned. -*/ -#if defined Q_CC_SUN -inline quint64 qFromLittleEndian_helper(const uchar *src, quint64 *dest) -{ - return 0 - | src[0] - | src[1] * Q_UINT64_C(0x0000000000000100) - | src[2] * Q_UINT64_C(0x0000000000010000) - | src[3] * Q_UINT64_C(0x0000000001000000) - | src[4] * Q_UINT64_C(0x0000000100000000) - | src[5] * Q_UINT64_C(0x0000010000000000) - | src[6] * Q_UINT64_C(0x0001000000000000) - | src[7] * Q_UINT64_C(0x0100000000000000); -} - -inline quint32 qFromLittleEndian_helper(const uchar *src, quint32 *dest) -{ - return 0 - | src[0] - | src[1] * quint32(0x00000100) - | src[2] * quint32(0x00010000) - | src[3] * quint32(0x01000000); -} - -inline quint16 qFromLittleEndian_helper(const uchar *src, quint16 *dest) -{ - return 0 - | src[0] - | src[1] * 0x0100; -} - -inline qint64 qFromLittleEndian_helper(const uchar *src, qint64 * dest) -{ return static_cast<qint64>(qFromLittleEndian_helper(src, reinterpret_cast<quint64*>(0))); } -inline qint32 qFromLittleEndian_helper(const uchar *src, qint32 * dest) -{ return static_cast<qint32>(qFromLittleEndian_helper(src, reinterpret_cast<quint32*>(0))); } -inline qint16 qFromLittleEndian_helper(const uchar *src, qint16 * dest) -{ return static_cast<qint16>(qFromLittleEndian_helper(src, reinterpret_cast<quint16*>(0))); } - -template <class T> inline T qFromLittleEndian(const uchar *src) -{ - return qFromLittleEndian_helper(src, reinterpret_cast<T*>(0)); -} - -#else -template <typename T> inline T qFromLittleEndian(const uchar *src); -template <> inline quint64 qFromLittleEndian<quint64>(const uchar *src) -{ - return 0 - | src[0] - | src[1] * Q_UINT64_C(0x0000000000000100) - | src[2] * Q_UINT64_C(0x0000000000010000) - | src[3] * Q_UINT64_C(0x0000000001000000) - | src[4] * Q_UINT64_C(0x0000000100000000) - | src[5] * Q_UINT64_C(0x0000010000000000) - | src[6] * Q_UINT64_C(0x0001000000000000) - | src[7] * Q_UINT64_C(0x0100000000000000); -} - -template <> inline quint32 qFromLittleEndian<quint32>(const uchar *src) -{ - return 0 - | src[0] - | src[1] * quint32(0x00000100) - | src[2] * quint32(0x00010000) - | src[3] * quint32(0x01000000); -} - -template <> inline quint16 qFromLittleEndian<quint16>(const uchar *src) -{ - return quint16(0 - | src[0] - | src[1] * 0x0100); -} - -// signed specializations -template <> inline qint64 qFromLittleEndian<qint64>(const uchar *src) -{ return static_cast<qint64>(qFromLittleEndian<quint64>(src)); } - -template <> inline qint32 qFromLittleEndian<qint32>(const uchar *src) -{ return static_cast<qint32>(qFromLittleEndian<quint32>(src)); } - -template <> inline qint16 qFromLittleEndian<qint16>(const uchar *src) -{ return static_cast<qint16>(qFromLittleEndian<quint16>(src)); } -#endif - -template <> inline quint8 qFromLittleEndian<quint8>(const uchar *src) -{ return static_cast<quint8>(src[0]); } -template <> inline qint8 qFromLittleEndian<qint8>(const uchar *src) -{ return static_cast<qint8>(src[0]); } - -/* This function will read a big-endian (also known as network order) encoded value from \a src - * and return the value in host-endian encoding. - * There is no requirement that \a src must be aligned. -*/ -#if defined Q_CC_SUN -inline quint64 qFromBigEndian_helper(const uchar *src, quint64 *dest) -{ - return 0 - | src[7] - | src[6] * Q_UINT64_C(0x0000000000000100) - | src[5] * Q_UINT64_C(0x0000000000010000) - | src[4] * Q_UINT64_C(0x0000000001000000) - | src[3] * Q_UINT64_C(0x0000000100000000) - | src[2] * Q_UINT64_C(0x0000010000000000) - | src[1] * Q_UINT64_C(0x0001000000000000) - | src[0] * Q_UINT64_C(0x0100000000000000); -} - -inline quint32 qFromBigEndian_helper(const uchar *src, quint32 * dest) -{ - return 0 - | src[3] - | src[2] * quint32(0x00000100) - | src[1] * quint32(0x00010000) - | src[0] * quint32(0x01000000); -} - -inline quint16 qFromBigEndian_helper(const uchar *src, quint16 * des) -{ - return 0 - | src[1] - | src[0] * 0x0100; -} - - -inline qint64 qFromBigEndian_helper(const uchar *src, qint64 * dest) -{ return static_cast<qint64>(qFromBigEndian_helper(src, reinterpret_cast<quint64*>(0))); } -inline qint32 qFromBigEndian_helper(const uchar *src, qint32 * dest) -{ return static_cast<qint32>(qFromBigEndian_helper(src, reinterpret_cast<quint32*>(0))); } -inline qint16 qFromBigEndian_helper(const uchar *src, qint16 * dest) -{ return static_cast<qint16>(qFromBigEndian_helper(src, reinterpret_cast<quint16*>(0))); } - -template <class T> inline T qFromBigEndian(const uchar *src) -{ - return qFromBigEndian_helper(src, reinterpret_cast<T*>(0)); -} - -#else -template <class T> inline T qFromBigEndian(const uchar *src); -template<> -inline quint64 qFromBigEndian<quint64>(const uchar *src) +template <typename T> inline T qFromUnaligned(const uchar *src) { - return 0 - | src[7] - | src[6] * Q_UINT64_C(0x0000000000000100) - | src[5] * Q_UINT64_C(0x0000000000010000) - | src[4] * Q_UINT64_C(0x0000000001000000) - | src[3] * Q_UINT64_C(0x0000000100000000) - | src[2] * Q_UINT64_C(0x0000010000000000) - | src[1] * Q_UINT64_C(0x0001000000000000) - | src[0] * Q_UINT64_C(0x0100000000000000); -} - -template<> -inline quint32 qFromBigEndian<quint32>(const uchar *src) -{ - return 0 - | src[3] - | src[2] * quint32(0x00000100) - | src[1] * quint32(0x00010000) - | src[0] * quint32(0x01000000); -} - -template<> -inline quint16 qFromBigEndian<quint16>(const uchar *src) -{ - return quint16( 0 - | src[1] - | src[0] * quint16(0x0100)); + T dest; + const size_t size = sizeof(T); + memcpy(&dest, src, size); + return dest; } - -// signed specializations -template <> inline qint64 qFromBigEndian<qint64>(const uchar *src) -{ return static_cast<qint64>(qFromBigEndian<quint64>(src)); } - -template <> inline qint32 qFromBigEndian<qint32>(const uchar *src) -{ return static_cast<qint32>(qFromBigEndian<quint32>(src)); } - -template <> inline qint16 qFromBigEndian<qint16>(const uchar *src) -{ return static_cast<qint16>(qFromBigEndian<quint16>(src)); } -#endif - -template <> inline quint8 qFromBigEndian<quint8>(const uchar *src) -{ return static_cast<quint8>(src[0]); } -template <> inline qint8 qFromBigEndian<qint8>(const uchar *src) -{ return static_cast<qint8>(src[0]); } - /* * T qbswap(T source). * Changes the byte order of a value from big endian to little endian or vice versa. @@ -289,6 +104,15 @@ template <> inline quint32 qbswap<quint32>(quint32 source) { return __builtin_bswap32(source); } + +template <> inline void qbswap<quint64>(quint64 source, uchar *dest) +{ + qToUnaligned<quint64>(__builtin_bswap64(source), dest); +} +template <> inline void qbswap<quint32>(quint32 source, uchar *dest) +{ + qToUnaligned<quint32>(__builtin_bswap32(source), dest); +} #else template <> inline quint64 qbswap<quint64>(quint64 source) { @@ -317,6 +141,10 @@ template <> inline quint16 qbswap<quint16>(quint16 source) { return __builtin_bswap16(source); } +template <> inline void qbswap<quint16>(quint16 source, uchar *dest) +{ + qToUnaligned<quint16>(__builtin_bswap16(source), dest); +} #else template <> inline quint16 qbswap<quint16>(quint16 source) { @@ -344,6 +172,21 @@ template <> inline qint16 qbswap<qint16>(qint16 source) return qbswap<quint16>(quint16(source)); } +template <> inline void qbswap<qint64>(qint64 source, uchar *dest) +{ + qbswap<quint64>(quint64(source), dest); +} + +template <> inline void qbswap<qint32>(qint32 source, uchar *dest) +{ + qbswap<quint32>(quint32(source), dest); +} + +template <> inline void qbswap<qint16>(qint16 source, uchar *dest) +{ + qbswap<quint16>(quint16(source), dest); +} + #if Q_BYTE_ORDER == Q_BIG_ENDIAN template <typename T> inline T qToBigEndian(T source) @@ -385,6 +228,35 @@ template <> inline qint8 qbswap<qint8>(qint8 source) return source; } +/* T qFromLittleEndian(const uchar *src) + * This function will read a little-endian encoded value from \a src + * and return the value in host-endian encoding. + * There is no requirement that \a src must be aligned. +*/ +template <typename T> inline T qFromLittleEndian(const uchar *src) +{ + return qFromLittleEndian(qFromUnaligned<T>(src)); +} + +template <> inline quint8 qFromLittleEndian<quint8>(const uchar *src) +{ return static_cast<quint8>(src[0]); } +template <> inline qint8 qFromLittleEndian<qint8>(const uchar *src) +{ return static_cast<qint8>(src[0]); } + +/* This function will read a big-endian (also known as network order) encoded value from \a src + * and return the value in host-endian encoding. + * There is no requirement that \a src must be aligned. +*/ +template <class T> inline T qFromBigEndian(const uchar *src) +{ + return qFromBigEndian(qFromUnaligned<T>(src)); +} + +template <> inline quint8 qFromBigEndian<quint8>(const uchar *src) +{ return static_cast<quint8>(src[0]); } +template <> inline qint8 qFromBigEndian<qint8>(const uchar *src) +{ return static_cast<qint8>(src[0]); } + QT_END_NAMESPACE #endif // QENDIAN_H diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 275ab12800..0b7b23e039 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -49,21 +49,21 @@ class QFlag { int i; public: - Q_DECL_CONSTEXPR inline QFlag(int ai) : i(ai) {} - Q_DECL_CONSTEXPR inline operator int() const { return i; } + Q_DECL_CONSTEXPR inline QFlag(int ai) Q_DECL_NOTHROW : i(ai) {} + Q_DECL_CONSTEXPR inline operator int() const Q_DECL_NOTHROW { 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))) {} + Q_DECL_CONSTEXPR inline QFlag(long ai) Q_DECL_NOTHROW : i(int(ai)) {} + Q_DECL_CONSTEXPR inline QFlag(ulong ai) Q_DECL_NOTHROW : i(int(long(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 uint() const { return uint(i); } + Q_DECL_CONSTEXPR inline QFlag(uint ai) Q_DECL_NOTHROW : i(int(ai)) {} + Q_DECL_CONSTEXPR inline QFlag(short ai) Q_DECL_NOTHROW : i(int(ai)) {} + Q_DECL_CONSTEXPR inline QFlag(ushort ai) Q_DECL_NOTHROW : i(int(uint(ai))) {} + Q_DECL_CONSTEXPR inline operator uint() const Q_DECL_NOTHROW { return uint(i); } #endif }; Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE); @@ -72,12 +72,12 @@ class QIncompatibleFlag { int i; public: - Q_DECL_CONSTEXPR inline explicit QIncompatibleFlag(int i); - Q_DECL_CONSTEXPR inline operator int() const { return i; } + Q_DECL_CONSTEXPR inline explicit QIncompatibleFlag(int i) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline operator int() const Q_DECL_NOTHROW { return i; } }; Q_DECLARE_TYPEINFO(QIncompatibleFlag, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {} +Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int ai) Q_DECL_NOTHROW : i(ai) {} #ifndef Q_NO_TYPESAFE_FLAGS @@ -108,41 +108,42 @@ public: inline QFlags(const QFlags &other); inline QFlags &operator=(const QFlags &other); #endif - Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(Int(f)) {} - Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {} - Q_DECL_CONSTEXPR inline QFlags(QFlag f) : i(f) {} + Q_DECL_CONSTEXPR inline QFlags(Enum f) Q_DECL_NOTHROW : i(Int(f)) {} + Q_DECL_CONSTEXPR inline QFlags(Zero = 0) Q_DECL_NOTHROW : i(0) {} + Q_DECL_CONSTEXPR inline QFlags(QFlag f) Q_DECL_NOTHROW : i(f) {} #ifdef Q_COMPILER_INITIALIZER_LISTS - Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) + Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) Q_DECL_NOTHROW : i(initializer_list_helper(flags.begin(), flags.end())) {} #endif - inline QFlags &operator&=(int mask) { i &= mask; return *this; } - inline QFlags &operator&=(uint mask) { i &= mask; return *this; } - inline QFlags &operator&=(Enum mask) { i &= Int(mask); return *this; } - inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; } - inline QFlags &operator|=(Enum f) { i |= Int(f); return *this; } - inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; } - inline QFlags &operator^=(Enum f) { i ^= Int(f); return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) Q_DECL_NOTHROW { i &= mask; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) Q_DECL_NOTHROW { i &= mask; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(Enum mask) Q_DECL_NOTHROW { i &= Int(mask); return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags f) Q_DECL_NOTHROW { i |= f.i; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum f) Q_DECL_NOTHROW { i |= Int(f); return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags f) Q_DECL_NOTHROW { i ^= f.i; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum f) Q_DECL_NOTHROW { i ^= Int(f); return *this; } - Q_DECL_CONSTEXPR inline operator Int() const { return i; } + Q_DECL_CONSTEXPR inline operator Int() const Q_DECL_NOTHROW { return i; } - Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(QFlag(i | f.i)); } - Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(QFlag(i | Int(f))); } - Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(QFlag(i ^ f.i)); } - Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(QFlag(i ^ Int(f))); } - Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(QFlag(i & Int(f))); } - Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(QFlag(~i)); } + Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const Q_DECL_NOTHROW { return QFlags(QFlag(i | f.i)); } + Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const Q_DECL_NOTHROW { return QFlags(QFlag(i | Int(f))); } + Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ f.i)); } + Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ Int(f))); } + Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const Q_DECL_NOTHROW { return QFlags(QFlag(i & Int(f))); } + Q_DECL_CONSTEXPR inline QFlags operator~() const Q_DECL_NOTHROW { return QFlags(QFlag(~i)); } - Q_DECL_CONSTEXPR inline bool operator!() const { return !i; } + Q_DECL_CONSTEXPR inline bool operator!() const Q_DECL_NOTHROW { return !i; } - Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const { return (i & Int(f)) == Int(f) && (Int(f) != 0 || i == Int(f) ); } + Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const Q_DECL_NOTHROW { return (i & Int(f)) == Int(f) && (Int(f) != 0 || i == Int(f) ); } private: #ifdef Q_COMPILER_INITIALIZER_LISTS Q_DECL_CONSTEXPR static inline Int initializer_list_helper(typename std::initializer_list<Enum>::const_iterator it, typename std::initializer_list<Enum>::const_iterator end) + Q_DECL_NOTHROW { return (it == end ? Int(0) : (Int(*it) | initializer_list_helper(it + 1, end))); } @@ -155,13 +156,13 @@ private: typedef QFlags<Enum> Flags; #define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \ -Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \ +Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) Q_DECL_NOTHROW \ { return QIncompatibleFlag(int(f1) | f2); } #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ -Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \ +Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) Q_DECL_NOTHROW \ { return QFlags<Flags::enum_type>(f1) | f2; } \ -Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \ +Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) Q_DECL_NOTHROW \ { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 997e804579..0a9e2f97db 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Intel Corporation ** Contact: http://www.qt-project.org/legal ** @@ -39,6 +39,7 @@ #include "qthreadstorage.h" #include "qdir.h" #include "qdatetime.h" +#include <private/qlocale_tools_p.h> #include <private/qsystemlibrary_p.h> @@ -548,9 +549,9 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); \snippet code/src_corelib_global_qglobal.cpp 3 <QtGlobal> also contains functions that generate messages from the - given string argument: qCritical(), qDebug(), qFatal() and - qWarning(). These functions call the message handler with the - given message. + given string argument: qDebug(), qInfo(), qWarning(), qCritical(), + and qFatal(). These functions call the message handler + with the given message. Example: @@ -769,6 +770,8 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); \value QtDebugMsg A message generated by the qDebug() function. + \value QtInfoMsg + A message generated by the qInfo() function. \value QtWarningMsg A message generated by the qWarning() function. \value QtCriticalMsg @@ -777,6 +780,7 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); A message generated by the qFatal() function. \value QtSystemMsg + \c QtInfoMsg was added in Qt 5.5. \sa QtMessageHandler, qInstallMessageHandler() */ @@ -986,9 +990,9 @@ bool qSharedBuild() Q_DECL_NOTHROW \li \l ByteOrder specifies whether the platform is big-endian or little-endian. \li \l WindowsVersion specifies the version of the Windows operating - system on which the application is run (Windows only) + system on which the application is run. \li \l MacintoshVersion specifies the version of the Macintosh - operating system on which the application is run (Mac only). + operating system on which the application is run. \endlist Some constants are defined only on certain platforms. You can use @@ -1011,7 +1015,7 @@ bool qSharedBuild() Q_DECL_NOTHROW /*! \variable QSysInfo::WindowsVersion \brief the version of the Windows operating system on which the - application is run (Windows only) + application is run. */ /*! @@ -1019,19 +1023,22 @@ bool qSharedBuild() Q_DECL_NOTHROW \since 4.4 Returns the version of the Windows operating system on which the - application is run (Windows only). + application is run, or WV_None if the operating system is not + Windows. */ /*! \variable QSysInfo::MacintoshVersion \brief the version of the Macintosh operating system on which - the application is run (Mac only). + the application is run. */ /*! \fn QSysInfo::MacVersion QSysInfo::macVersion() - Returns the version of Darwin (OS X or iOS) on which the application is run. + Returns the version of Darwin (OS X or iOS) on which the + application is run, or MV_None if the operating system + is not a version of Darwin. */ /*! @@ -1068,6 +1075,7 @@ bool qSharedBuild() Q_DECL_NOTHROW \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 + \value WV_WINDOWS10 Windows 10 (operating system version 10.0), introduced in Qt 5.5 Alternatively, you may use the following macros which correspond directly to the Windows operating system version number: @@ -1079,6 +1087,7 @@ bool qSharedBuild() Q_DECL_NOTHROW \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 + \value WV_10_0 Operating system version 10.0, corresponds to Windows 10, introduced in Qt 5.5 CE-based versions: @@ -1094,6 +1103,8 @@ bool qSharedBuild() Q_DECL_NOTHROW \value WV_NT_based NT-based version of Windows \value WV_CE_based CE-based version of Windows + \value WV_None Operating system other than Windows. + \sa MacVersion */ @@ -1141,6 +1152,8 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_IOS_7_1 iOS 7.1 \value MV_IOS_8_0 iOS 8.0 + \value MV_None Not a Darwin operating system + \sa WinVersion */ @@ -1847,16 +1860,14 @@ Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { QSysInfo::MacVersion QSysInfo::macVersion() { + const QAppleOperatingSystemVersion version = qt_apple_os_version(); // qtcore_mac_objc.mm #if defined(Q_OS_OSX) - SInt32 gestalt_version; - if (Gestalt(gestaltSystemVersionMinor, &gestalt_version) == noErr) { - // add 2 because OS X 10.0 is 0x02 in the enum - return QSysInfo::MacVersion(gestalt_version + 2); - } + return QSysInfo::MacVersion(Q_MV_OSX(version.major, version.minor)); #elif defined(Q_OS_IOS) - return qt_ios_version(); // qtcore_mac_objc.mm -#endif + return QSysInfo::MacVersion(Q_MV_IOS(version.major, version.minor)); +#else return QSysInfo::MV_Unknown; +#endif } const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion(); @@ -2024,6 +2035,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion() winver = QSysInfo::WV_WINDOWS8; } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) { winver = QSysInfo::WV_WINDOWS8_1; + } else if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0) { + winver = QSysInfo::WV_WINDOWS10; } else { qWarning("Qt: Untested Windows version %d.%d detected!", int(osver.dwMajorVersion), int(osver.dwMinorVersion)); @@ -2516,6 +2529,9 @@ QString QSysInfo::productType() #elif defined(Q_OS_DARWIN) return QStringLiteral("darwin"); +#elif defined(Q_OS_HAIKU) + return QStringLiteral("haiku"); + #elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX QUnixOSVersion unixOsVersion; readEtcOsRelease(unixOsVersion); @@ -2551,25 +2567,9 @@ QString QSysInfo::productType() */ QString QSysInfo::productVersion() { -#if defined(Q_OS_IOS) - int major = (int(MacintoshVersion) >> 4) & 0xf; - int minor = int(MacintoshVersion) & 0xf; - if (Q_LIKELY(major < 10 && minor < 10)) { - char buf[4] = { char(major + '0'), '.', char(minor + '0'), '\0' }; - return QString::fromLatin1(buf, 3); - } - return QString::number(major) + QLatin1Char('.') + QString::number(minor); -#elif defined(Q_OS_OSX) - int minor = int(MacintoshVersion) - 2; // we're not running on Mac OS 9 - Q_ASSERT(minor < 100); - char buf[] = "10.0\0"; - if (Q_LIKELY(minor < 10)) { - buf[3] += minor; - } else { - buf[3] += minor / 10; - buf[4] = '0' + minor % 10; - } - return QString::fromLatin1(buf); +#if defined(Q_OS_MAC) + const QAppleOperatingSystemVersion version = qt_apple_os_version(); + return QString::number(version.major) + QLatin1Char('.') + QString::number(version.minor); #elif defined(Q_OS_WIN) const char *version = winVer_helper(); if (version) @@ -2662,6 +2662,8 @@ QString QSysInfo::prettyProductName() return QLatin1String("Android ") + productVersion(); #elif defined(Q_OS_BLACKBERRY) return QLatin1String("BlackBerry ") + productVersion(); +#elif defined(Q_OS_HAIKU) + return QLatin1String("Haiku ") + productVersion(); #elif defined(Q_OS_UNIX) # ifdef USE_ETC_OS_RELEASE QUnixOSVersion unixOsVersion; @@ -3065,6 +3067,53 @@ bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT /*! \relates <QtGlobal> + \since 5.5 + + Returns the numerical value of the environment variable \a varName. + If \a ok is not null, sets \c{*ok} to \c true or \c false depending + on the success of the conversion. + + Equivalent to + \code + qgetenv(varName).toInt() + \endcode + except that it's much faster, and can't throw exceptions. + + \sa qgetenv(), qEnvironmentVariableIsSet() +*/ +int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT +{ +#if defined(_MSC_VER) && _MSC_VER >= 1400 + // we provide a buffer that can hold any int value: + static const int NumBinaryDigitsPerOctalDigit = 3; + static const int MaxDigitsForOctalInt = + (std::numeric_limits<uint>::digits + NumBinaryDigitsPerOctalDigit - 1) / NumBinaryDigitsPerOctalDigit; + char buffer[MaxDigitsForOctalInt + 2]; // +1 for NUL +1 for optional '-' + size_t dummy; + if (getenv_s(&dummy, buffer, sizeof buffer, varName) != 0) { + if (ok) + *ok = false; + return 0; + } +#else + const char * const buffer = ::getenv(varName); + if (!buffer || !*buffer) { + if (ok) + *ok = false; + return 0; + } +#endif + const qlonglong value = qstrtoll(buffer, Q_NULLPTR, 0, ok); + if (int(value) != value) { // this is the check in QByteArray::toInt(), keep it in sync + if (ok) + *ok = false; + return 0; + } + return int(value); +} + +/*! + \relates <QtGlobal> \since 5.1 Returns whether the environment variable \a varName is set. @@ -3556,8 +3605,8 @@ int qrand() qPrintable() is used. This is because the array returned by QString::toLocal8Bit() will fall out of scope. - \note qDebug(), qWarning(), qCritical(), qFatal() expect %s - arguments to be UTF-8 encoded, while qPrintable() converts to + \note qDebug(), qInfo(), qWarning(), qCritical(), qFatal() expect + %s arguments to be UTF-8 encoded, while qPrintable() converts to local 8-bit encoding. Therefore qUtf8Printable() should be used for logging strings instead of qPrintable(). @@ -3580,7 +3629,7 @@ int qrand() \snippet code/src_corelib_global_qglobal.cpp 37 - \sa qPrintable(), qDebug(), qWarning(), qCritical(), qFatal() + \sa qPrintable(), qDebug(), qInfo(), qWarning(), qCritical(), qFatal() */ /*! @@ -3968,6 +4017,21 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) It expands to "constexpr" if your compiler supports that C++11 keyword, or to nothing otherwise. + + \sa Q_DECL_RELAXED_CONSTEXPR +*/ + +/*! + \macro Q_DECL_RELAXED_CONSTEXPR + \relates <QtGlobal> + + This macro can be used to declare an inline function that can be computed + at compile-time according to the relaxed rules from C++14. + + It expands to "constexpr" if your compiler supports C++14 relaxed constant + expressions, or to nothing otherwise. + + \sa Q_DECL_CONSTEXPR */ /*! @@ -3976,8 +4040,8 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) Calls the message handler with the debug message \a message. If no message handler has been installed, the message is printed to - stderr. Under Windows, the message is sent to the console, if it is a - console application; otherwise, it is sent to the debugger. On Blackberry the + stderr. Under Windows the message is sent to the console, if it is a + console application; otherwise, it is sent to the debugger. On Blackberry, the message is sent to slogger2. This function does nothing if \c QT_NO_DEBUG_OUTPUT was defined during compilation. @@ -4002,7 +4066,44 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) To suppress the output at run-time, install your own message handler with qInstallMessageHandler(). - \sa qWarning(), qCritical(), qFatal(), qInstallMessageHandler(), + \sa qInfo(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(), + {Debugging Techniques} +*/ + +/*! + \macro qInfo(const char *message, ...) + \relates <QtGlobal> + \since 5.5 + + Calls the message handler with the informational message \a message. If no + message handler has been installed, the message is printed to + stderr. Under Windows, the message is sent to the console, if it is a + console application; otherwise, it is sent to the debugger. On Blackberry the + message is sent to slogger2. This function does nothing if \c QT_NO_INFO_OUTPUT + was defined during compilation. + + If you pass the function a format string and a list of arguments, + it works in similar way to the C printf() function. The format + should be a Latin-1 string. + + Example: + + \snippet code/src_corelib_global_qglobal.cpp qInfo_printf + + If you include \c <QtDebug>, a more convenient syntax is also + available: + + \snippet code/src_corelib_global_qglobal.cpp qInfo_stream + + With this syntax, the function returns a QDebug object that is + configured to use the QtInfoMsg message type. It automatically + puts a single space between each item, and outputs a newline at + the end. It supports many C++ and Qt types. + + To suppress the output at run-time, install your own message handler + with qInstallMessageHandler(). + + \sa qDebug(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(), {Debugging Techniques} */ @@ -4036,7 +4137,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) To suppress the output at runtime, install your own message handler with qInstallMessageHandler(). - \sa qDebug(), qCritical(), qFatal(), qInstallMessageHandler(), + \sa qDebug(), qInfo(), qCritical(), qFatal(), qInstallMessageHandler(), {Debugging Techniques} */ @@ -4069,7 +4170,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) To suppress the output at runtime, install your own message handler with qInstallMessageHandler(). - \sa qDebug(), qWarning(), qFatal(), qInstallMessageHandler(), + \sa qDebug(), qInfo(), qWarning(), qFatal(), qInstallMessageHandler(), {Debugging Techniques} */ @@ -4096,7 +4197,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) To suppress the output at runtime, install your own message handler with qInstallMessageHandler(). - \sa qDebug(), qCritical(), qWarning(), qInstallMessageHandler(), + \sa qDebug(), qInfo(), qWarning(), qCritical(), qInstallMessageHandler(), {Debugging Techniques} */ diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index dade7fc6ec..863e499667 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -35,13 +35,17 @@ #ifndef QGLOBAL_H #define QGLOBAL_H +#ifdef __cplusplus +# include <cstddef> +#endif + #include <stddef.h> -#define QT_VERSION_STR "5.4.2" +#define QT_VERSION_STR "5.5.0" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050402 +#define QT_VERSION 0x050500 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ @@ -481,6 +485,14 @@ typedef qptrdiff qintptr; # define Q_ATTRIBUTE_FORMAT_PRINTF(A, B) #endif +#ifdef Q_CC_MSVC +# define Q_NEVER_INLINE __declspec(noinline) +#elif defined(Q_CC_GNU) +# define Q_NEVER_INLINE __attribute__((noinline)) +#else +# define Q_NEVER_INLINE +#endif + //defines the type for the WNDPROC on windows //the alignment needs to be forced for sse2 to not crash with mingw #if defined(Q_OS_WIN) @@ -620,14 +632,7 @@ Q_CORE_EXPORT bool qSharedBuild() Q_DECL_NOTHROW; /* Avoid "unused parameter" warnings */ - -#if defined(Q_CC_RVCT) -template <typename T> -inline void qUnused(T &x) { (void)x; } -# define Q_UNUSED(x) qUnused(x); -#else -# define Q_UNUSED(x) (void)x; -#endif +#define Q_UNUSED(x) (void)x; /* Debugging and error handling @@ -655,7 +660,7 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) #if !defined(Q_ASSERT) # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) -# define Q_ASSERT(cond) qt_noop() +# define Q_ASSERT(cond) do { } while (false && (cond)) # else # define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop()) # endif @@ -805,8 +810,20 @@ static inline bool qIsNull(float f) # define Q_DUMMY_COMPARISON_OPERATOR(C) #endif +namespace QtPrivate +{ +namespace SwapExceptionTester { // insulate users from the "using std::swap" below + using std::swap; // import std::swap + template <typename T> + void checkSwap(T &t) + Q_DECL_NOEXCEPT_EXPR(noexcept(swap(t, t))); + // declared, but not implemented (only to be used in unevaluated contexts (noexcept operator)) +} +} // namespace QtPrivate + template <typename T> inline void qSwap(T &value1, T &value2) + Q_DECL_NOEXCEPT_EXPR(noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1))) { using std::swap; swap(value1, value2); @@ -834,22 +851,22 @@ Q_CORE_EXPORT void qFreeAligned(void *ptr); #endif #if defined(QT_NO_WARNINGS) # if defined(Q_CC_MSVC) -# pragma warning(disable: 4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */ -# pragma warning(disable: 4244) /* conversion from 'type1' to 'type2', possible loss of data */ -# pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */ -# pragma warning(disable: 4514) /* unreferenced inline function has been removed */ -# pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */ -# pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */ -# pragma warning(disable: 4706) /* assignment within conditional expression */ +QT_WARNING_DISABLE_MSVC(4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */ +QT_WARNING_DISABLE_MSVC(4244) /* conversion from 'type1' to 'type2', possible loss of data */ +QT_WARNING_DISABLE_MSVC(4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */ +QT_WARNING_DISABLE_MSVC(4514) /* unreferenced inline function has been removed */ +QT_WARNING_DISABLE_MSVC(4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */ +QT_WARNING_DISABLE_MSVC(4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */ +QT_WARNING_DISABLE_MSVC(4706) /* assignment within conditional expression */ # if _MSC_VER <= 1310 // MSVC 2003 -# pragma warning(disable: 4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */ +QT_WARNING_DISABLE_MSVC(4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */ # endif -# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */ +QT_WARNING_DISABLE_MSVC(4355) /* 'this' : used in base member initializer list */ # if _MSC_VER < 1800 // MSVC 2013 -# pragma warning(disable: 4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */ +QT_WARNING_DISABLE_MSVC(4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */ # endif -# pragma warning(disable: 4710) /* function not inlined */ -# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */ +QT_WARNING_DISABLE_MSVC(4710) /* function not inlined */ +QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */ # elif defined(Q_CC_BOR) # pragma option -w-inl # pragma option -w-aus @@ -861,7 +878,7 @@ Q_CORE_EXPORT void qFreeAligned(void *ptr); # endif #endif -#if defined(Q_COMPILER_DECLTYPE) || (defined(Q_CC_GNU) && !defined(Q_CC_RVCT)) +#if defined(Q_COMPILER_DECLTYPE) || defined(Q_CC_GNU) /* make use of decltype or GCC's __typeof__ extension */ template <typename T> class QForeachContainer { @@ -1027,6 +1044,7 @@ Q_CORE_EXPORT bool qunsetenv(const char *varName); Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT; Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT; +Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=0) Q_DECL_NOEXCEPT; inline int qIntCast(double f) { return int(f); } inline int qIntCast(float f) { return int(f); } @@ -1039,13 +1057,6 @@ Q_CORE_EXPORT int qrand(); #define QT_MODULE(x) -#ifdef Q_OS_QNX -// QNX doesn't have SYSV style shared memory. Multiprocess QWS apps, -// shared fonts and QSystemSemaphore + QSharedMemory are not available -# define QT_NO_SYSTEMSEMAPHORE -# define QT_NO_SHAREDMEMORY -#endif - #if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) # error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ "Compile your code with -fPIC or -fPIE." diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp index 7638414cf1..39ed87e789 100644 --- a/src/corelib/global/qhooks.cpp +++ b/src/corelib/global/qhooks.cpp @@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE // Only add to the end, and bump version if you do. quintptr Q_CORE_EXPORT qtHookData[] = { - 1, // hook data version + 2, // hook data version QHooks::LastHookIndex, // size of qtHookData QT_VERSION, diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index d592032c1f..b47015cbc9 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -41,16 +41,8 @@ #ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE -extern QString qt_libraryInfoFile(); +extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE -#elif defined(QT_BOOTSTRAPPED) -QString qt_libraryInfoFile() -{ - QString qmakeAbsoluteLocation = QLatin1String(QT_QMAKE_LOCATION); - if (!qmakeAbsoluteLocation.isEmpty()) - return QDir(QFileInfo(qmakeAbsoluteLocation).absolutePath()).filePath(QLatin1String("qt.conf")); - return QString(); -} #else # include "qcoreapplication.h" #endif @@ -72,7 +64,8 @@ struct QLibrarySettings { QLibrarySettings(); QScopedPointer<QSettings> settings; -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE + bool haveDevicePaths; bool haveEffectiveSourcePaths; bool haveEffectivePaths; bool havePaths; @@ -84,14 +77,17 @@ class QLibraryInfoPrivate { public: static QSettings *findConfiguration(); -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE static bool haveGroup(QLibraryInfo::PathGroup group) { QLibrarySettings *ls = qt_library_settings(); return ls ? (group == QLibraryInfo::EffectiveSourcePaths ? ls->haveEffectiveSourcePaths : group == QLibraryInfo::EffectivePaths - ? ls->haveEffectivePaths : ls->havePaths) : false; + ? ls->haveEffectivePaths + : group == QLibraryInfo::DevicePaths + ? ls->haveDevicePaths + : ls->havePaths) : false; } #endif static QSettings *configuration() @@ -106,7 +102,8 @@ static const char platformsSection[] = "Platforms"; QLibrarySettings::QLibrarySettings() : settings(QLibraryInfoPrivate::findConfiguration()) { -#ifndef QT_BOOTSTRAPPED +#ifndef QT_BUILD_QMAKE + bool haveDevicePaths; bool haveEffectivePaths; bool havePaths; #endif @@ -114,7 +111,8 @@ QLibrarySettings::QLibrarySettings() // This code needs to be in the regular library, as otherwise a qt.conf that // works for qmake would break things for dynamically built Qt tools. QStringList children = settings->childGroups(); -#ifdef QT_BOOTSTRAPPED + haveDevicePaths = children.contains(QLatin1String("DevicePaths")); +#ifdef QT_BUILD_QMAKE haveEffectiveSourcePaths = children.contains(QLatin1String("EffectiveSourcePaths")); #else // EffectiveSourcePaths is for the Qt build only, so needs no backwards compat trickery. @@ -122,13 +120,15 @@ QLibrarySettings::QLibrarySettings() #endif haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths")); // Backwards compat: an existing but empty file is claimed to contain the Paths section. - havePaths = (!haveEffectivePaths && !children.contains(QLatin1String(platformsSection))) + havePaths = (!haveDevicePaths && !haveEffectivePaths + && !children.contains(QLatin1String(platformsSection))) || children.contains(QLatin1String("Paths")); -#ifndef QT_BOOTSTRAPPED +#ifndef QT_BUILD_QMAKE if (!havePaths) settings.reset(0); #else } else { + haveDevicePaths = false; haveEffectiveSourcePaths = false; haveEffectivePaths = false; havePaths = false; @@ -139,9 +139,9 @@ QLibrarySettings::QLibrarySettings() QSettings *QLibraryInfoPrivate::findConfiguration() { QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE if(!QFile::exists(qtconfig)) - qtconfig = qt_libraryInfoFile(); + qtconfig = qmake_libraryInfoFile(); #else if (!QFile::exists(qtconfig) && QCoreApplication::instance()) { #ifdef Q_OS_MAC @@ -189,7 +189,7 @@ QSettings *QLibraryInfoPrivate::findConfiguration() \sa QSysInfo, {Using qt.conf} */ -#ifndef QT_BOOTSTRAPPED +#ifndef QT_BUILD_QMAKE /*! \internal @@ -287,6 +287,8 @@ QLibraryInfo::buildDate() # define COMPILER_STRING "MSVC 2012" # elif _MSC_VER < 1900 # define COMPILER_STRING "MSVC 2013" +# elif _MSC_VER < 2000 +# define COMPILER_STRING "MSVC 2015" # else # define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER) # endif @@ -333,7 +335,7 @@ QLibraryInfo::isDebugBuild() #endif } -#endif // QT_BOOTSTRAPPED +#endif // QT_BUILD_QMAKE /* * To add a new entry in QLibrary::LibraryLocation, add it to the enum above the bootstrapped values and: @@ -365,14 +367,14 @@ static const struct { { "Translations", "translations" }, // should be ${Data}/translations { "Examples", "examples" }, { "Tests", "tests" }, -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE { "Sysroot", "" }, - { "HostPrefix", "" }, { "HostBinaries", "bin" }, { "HostLibraries", "lib" }, { "HostData", "." }, { "TargetSpec", "" }, { "HostSpec", "" }, + { "HostPrefix", "" }, #endif }; @@ -383,11 +385,11 @@ static const struct { QString QLibraryInfo::location(LibraryLocation loc) { -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE QString ret = rawLocation(loc, FinalPaths); // Automatically prepend the sysroot to target paths - if ((loc < SysrootPath || loc > LastHostPath) && qt_sysrootify_prefix[12] == 'y') { + if ((loc < SysrootPath || loc > LastHostPath) && QT_CONFIGURE_SYSROOTIFY_PREFIX) { QString sysroot = rawLocation(SysrootPath, FinalPaths); if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) @@ -402,33 +404,45 @@ QLibraryInfo::location(LibraryLocation loc) QString QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) { -#else -# define rawLocation(loca, group) location(loca) -# define group dummy #endif QString ret; -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE // Logic for choosing the right data source: if EffectivePaths are requested // and qt.conf with that section is present, use it, otherwise fall back to // FinalPaths. For FinalPaths, use qt.conf if present and contains not only // [EffectivePaths], otherwise fall back to builtins. // EffectiveSourcePaths falls back to EffectivePaths. + // DevicePaths falls back to FinalPaths. + PathGroup orig_group = group; if (!QLibraryInfoPrivate::haveGroup(group) && !(group == EffectiveSourcePaths && (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group))) - && !(group == EffectivePaths - && (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))) + && !((group == EffectivePaths || group == DevicePaths) + && (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group))) + && (group = orig_group, true)) #elif !defined(QT_NO_SETTINGS) if (!QLibraryInfoPrivate::configuration()) #endif { const char *path = 0; - if (unsigned(loc) < sizeof(qt_configure_prefix_path_strs)/sizeof(qt_configure_prefix_path_strs[0])) - path = qt_configure_prefix_path_strs[loc] + 12; + if (loc == PrefixPath) { + path = +#ifdef QT_BUILD_QMAKE + (group != DevicePaths) ? + QT_CONFIGURE_EXT_PREFIX_PATH : +#endif + QT_CONFIGURE_PREFIX_PATH; + } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { + path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; #ifndef Q_OS_WIN // On Windows we use the registry - else if (loc == SettingsPath) + } else if (loc == SettingsPath) { path = QT_CONFIGURE_SETTINGS_PATH; #endif +#ifdef QT_BUILD_QMAKE + } else if (loc == HostPrefixPath) { + path = QT_CONFIGURE_HOST_PREFIX_PATH; +#endif + } if (path) ret = QString::fromLocal8Bit(path); @@ -448,7 +462,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) if(!key.isNull()) { QSettings *config = QLibraryInfoPrivate::configuration(); config->beginGroup(QLatin1String( -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE + group == DevicePaths ? "DevicePaths" : group == EffectiveSourcePaths ? "EffectiveSourcePaths" : group == EffectivePaths ? "EffectivePaths" : #endif @@ -456,13 +471,13 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) ret = config->value(key, defaultValue).toString(); -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE if (ret.isEmpty()) { if (loc == HostPrefixPath) ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key), QLatin1String(qtConfEntries[PrefixPath].value)).toString(); else if (loc == TargetSpecPath || loc == HostSpecPath) - ret = QString::fromLocal8Bit(qt_configure_prefix_path_strs[loc] + 12); + ret = QString::fromLocal8Bit(qt_configure_strs + qt_configure_str_offsets[loc - 1]); } #endif @@ -483,7 +498,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) #endif // QT_NO_SETTINGS } -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE // The specs need to be returned verbatim. if (loc == TargetSpecPath || loc == HostSpecPath) return ret; @@ -491,15 +506,18 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) if (!ret.isEmpty() && QDir::isRelativePath(ret)) { QString baseDir; -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE if (loc == HostPrefixPath || loc == PrefixPath || loc == SysrootPath) { // We make the prefix/sysroot path absolute to the executable's directory. // loc == PrefixPath while a sysroot is set would make no sense here. // loc == SysrootPath only makes sense if qmake lives inside the sysroot itself. - baseDir = QFileInfo(qt_libraryInfoFile()).absolutePath(); + baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); } else if (loc > SysrootPath && loc <= LastHostPath) { // We make any other host path absolute to the host prefix directory. baseDir = rawLocation(HostPrefixPath, group); + } else { + // we make any other path absolute to the prefix directory + baseDir = rawLocation(PrefixPath, group); #else if (loc == PrefixPath) { if (QCoreApplication::instance()) { @@ -524,10 +542,10 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) } else { baseDir = QDir::currentPath(); } -#endif } else { // we make any other path absolute to the prefix directory - baseDir = rawLocation(PrefixPath, group); + baseDir = location(PrefixPath); +#endif } ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret); } @@ -549,7 +567,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) { -#if !defined(QT_BOOTSTRAPPED) && !defined(QT_NO_SETTINGS) +#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) QScopedPointer<const QSettings> settings(QLibraryInfoPrivate::findConfiguration()); if (!settings.isNull()) { QString key = QLatin1String(platformsSection); @@ -558,7 +576,7 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) key += QLatin1String("Arguments"); return settings->value(key).toStringList(); } -#endif // !QT_BOOTSTRAPPED && !QT_NO_SETTINGS +#endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS return QStringList(); } @@ -612,9 +630,9 @@ void qt_core_boilerplate() "Library path: %s\n" "Include path: %s\n", qt_configure_installation + 12, - qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::PrefixPath] + 12, - qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::LibrariesPath] + 12, - qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::HeadersPath] + 12); + qt_configure_prefix_path_str + 12, + qt_configure_strs + qt_configure_str_offsets[QT_PREPEND_NAMESPACE(QLibraryInfo)::LibrariesPath - 1], + qt_configure_strs + qt_configure_str_offsets[QT_PREPEND_NAMESPACE(QLibraryInfo)::HeadersPath - 1]); QT_PREPEND_NAMESPACE(qDumpCPUFeatures)(); diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 543c4b3828..4dff8ca494 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -73,22 +73,22 @@ public: TestsPath, // Insert new values above this line // Please read the comments in qlibraryinfo.cpp before adding -#ifdef QT_BOOTSTRAPPED +#ifdef QT_BUILD_QMAKE // These are not subject to binary compatibility constraints SysrootPath, - HostPrefixPath, HostBinariesPath, HostLibrariesPath, HostDataPath, TargetSpecPath, HostSpecPath, - LastHostPath = HostSpecPath, + HostPrefixPath, + LastHostPath = HostPrefixPath, #endif SettingsPath = 100 }; static QString location(LibraryLocation); // ### Qt 6: consider renaming it to path() -#ifdef QT_BOOTSTRAPPED - enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths }; +#ifdef QT_BUILD_QMAKE + enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths }; static QString rawLocation(LibraryLocation, PathGroup); #endif diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 50d35a6d84..2f3b5606f6 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com> ** Copyright (C) 2014 Intel Corporation. ** Contact: http://www.qt-project.org/legal @@ -76,7 +76,8 @@ # define __has_include(x) 0 #endif -#if !defined QT_NO_REGULAREXPRESSION && !defined(QT_BOOTSTRAPPED) +#ifndef QT_BOOTSTRAPPED +#if !defined QT_NO_REGULAREXPRESSION # if (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include(<cxxabi.h>) && __has_include(<execinfo.h>)) # define QLOGGING_HAVE_BACKTRACE # include <qregularexpression.h> @@ -85,6 +86,38 @@ # endif #endif +#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || __has_include(<sys/syscall.h>)) +# include <sys/syscall.h> +static long qt_gettid() +{ + // no error handling + // this syscall has existed since Linux 2.4.11 and cannot fail + return syscall(SYS_gettid); +} +#elif defined(Q_OS_DARWIN) +# include <pthread.h> +static int qt_gettid() +{ + // no error handling: this call cannot fail + __uint64_t tid; + pthread_threadid_np(NULL, &tid); + return tid; +} +#elif defined(Q_OS_FREEBSD_KERNEL) && defined(__FreeBSD_version) && __FreeBSD_version >= 900031 +# include <pthread_np.h> +static int qt_gettid() +{ + return pthread_getthreadid_np(); +} +#else +static QT_PREPEND_NAMESPACE(qint64) qt_gettid() +{ + QT_USE_NAMESPACE + return qintptr(QThread::currentThreadId()); +} +#endif +#endif // !QT_BOOTSTRAPPED + #include <stdio.h> QT_BEGIN_NAMESPACE @@ -168,7 +201,7 @@ Q_CORE_EXPORT bool qt_logging_to_console() \brief The QMessageLogContext class provides additional information about a log message. \since 5.0 - The class provides information about the source code location a qDebug(), qWarning(), + The class provides information about the source code location a qDebug(), qInfo(), qWarning(), qCritical() or qFatal() message was generated. \note By default, this information is recorded only in debug builds. You can overwrite @@ -184,7 +217,7 @@ Q_CORE_EXPORT bool qt_logging_to_console() \since 5.0 QMessageLogger is used to generate messages for the Qt logging framework. Usually one uses - it through qDebug(), qWarning(), qCritical, or qFatal() functions, + it through qDebug(), qInfo(), qWarning(), qCritical, or qFatal() functions, which are actually macros: For example qDebug() expands to QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug() for debug builds, and QMessageLogger(0, 0, 0).debug() for release builds. @@ -193,7 +226,7 @@ Q_CORE_EXPORT bool qt_logging_to_console() \snippet code/qlogging/qlogging.cpp 1 - \sa QMessageLogContext, qDebug(), qWarning(), qCritical(), qFatal() + \sa QMessageLogContext, qDebug(), qInfo(), qWarning(), qCritical(), qFatal() */ #ifdef Q_OS_WIN @@ -244,6 +277,28 @@ void QMessageLogger::debug(const char *msg, ...) const qt_message_fatal(QtDebugMsg, context, message); } + +#undef qInfo +/*! + Logs an informational message specified with format \a msg. Additional + parameters, specified by \a msg, may be used. + + \sa qInfo() + \since 5.5 +*/ +void QMessageLogger::info(const char *msg, ...) const +{ + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtInfoMsg, context, msg, ap, message); + va_end(ap); + + if (isFatal(QtInfoMsg)) + qt_message_fatal(QtInfoMsg, context, message); +} + /*! \typedef QMessageLogger::CategoryFunction @@ -373,6 +428,110 @@ QNoDebug QMessageLogger::noDebug() const Q_DECL_NOTHROW #endif +/*! + Logs an informational message specified with format \a msg for the context \a cat. + Additional parameters, specified by \a msg, may be used. + + \since 5.5 + \sa qCInfo() +*/ +void QMessageLogger::info(const QLoggingCategory &cat, const char *msg, ...) const +{ + if (!cat.isInfoEnabled()) + return; + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtInfoMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtInfoMsg)) + qt_message_fatal(QtInfoMsg, ctxt, message); +} + +/*! + Logs an informational message specified with format \a msg for the context returned + by \a catFunc. Additional parameters, specified by \a msg, may be used. + + \since 5.5 + \sa qCInfo() +*/ +void QMessageLogger::info(QMessageLogger::CategoryFunction catFunc, + const char *msg, ...) const +{ + const QLoggingCategory &cat = (*catFunc)(); + if (!cat.isInfoEnabled()) + return; + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtInfoMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtInfoMsg)) + qt_message_fatal(QtInfoMsg, ctxt, message); +} + +#ifndef QT_NO_DEBUG_STREAM + +/*! + Logs an informational message using a QDebug stream. + + \since 5.5 + \sa qInfo(), QDebug +*/ +QDebug QMessageLogger::info() const +{ + QDebug dbg = QDebug(QtInfoMsg); + QMessageLogContext &ctxt = dbg.stream->context; + ctxt.copy(context); + return dbg; +} + +/*! + Logs an informational message into the category \a cat using a QDebug stream. + + \since 5.5 + \sa qCInfo(), QDebug +*/ +QDebug QMessageLogger::info(const QLoggingCategory &cat) const +{ + QDebug dbg = QDebug(QtInfoMsg); + if (!cat.isInfoEnabled()) + dbg.stream->message_output = false; + + QMessageLogContext &ctxt = dbg.stream->context; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + return dbg; +} + +/*! + Logs an informational message into category returned by \a catFunc using a QDebug stream. + + \since 5.5 + \sa qCInfo(), QDebug +*/ +QDebug QMessageLogger::info(QMessageLogger::CategoryFunction catFunc) const +{ + return info((*catFunc)()); +} + +#endif + #undef qWarning /*! Logs a warning message specified with format \a msg. Additional @@ -802,10 +961,12 @@ static const char functionTokenC[] = "%{function}"; static const char pidTokenC[] = "%{pid}"; static const char appnameTokenC[] = "%{appname}"; static const char threadidTokenC[] = "%{threadid}"; +static const char qthreadptrTokenC[] = "%{qthreadptr}"; static const char timeTokenC[] = "%{time"; //not a typo: this command has arguments static const char backtraceTokenC[] = "%{backtrace"; //ditto static const char ifCategoryTokenC[] = "%{if-category}"; static const char ifDebugTokenC[] = "%{if-debug}"; +static const char ifInfoTokenC[] = "%{if-info}"; static const char ifWarningTokenC[] = "%{if-warning}"; static const char ifCriticalTokenC[] = "%{if-critical}"; static const char ifFatalTokenC[] = "%{if-fatal}"; @@ -825,6 +986,9 @@ struct QMessagePattern { const char **literals; const char **tokens; QString timeFormat; +#ifndef QT_BOOTSTRAPPED + QElapsedTimer timer; +#endif #ifdef QLOGGING_HAVE_BACKTRACE int backtraceDepth; QString backtraceSeparator; @@ -832,10 +996,6 @@ struct QMessagePattern { bool fromEnvironment; static QBasicMutex mutex; -#ifndef QT_BOOTSTRAPPED - QElapsedTimer timer; - QDateTime startTime; -#endif }; QBasicMutex QMessagePattern::mutex; @@ -848,9 +1008,6 @@ QMessagePattern::QMessagePattern() , backtraceSeparator(QLatin1Char('|')) #endif , fromEnvironment(false) -#ifndef QT_BOOTSTRAPPED - , startTime(QDateTime::currentDateTime()) -#endif { #ifndef QT_BOOTSTRAPPED timer.start(); @@ -942,6 +1099,8 @@ void QMessagePattern::setPattern(const QString &pattern) tokens[i] = appnameTokenC; else if (lexeme == QLatin1String(threadidTokenC)) tokens[i] = threadidTokenC; + else if (lexeme == QLatin1String(qthreadptrTokenC)) + tokens[i] = qthreadptrTokenC; else if (lexeme.startsWith(QLatin1String(timeTokenC))) { tokens[i] = timeTokenC; int spaceIdx = lexeme.indexOf(QChar::fromLatin1(' ')); @@ -977,6 +1136,7 @@ void QMessagePattern::setPattern(const QString &pattern) } IF_TOKEN(ifCategoryTokenC) IF_TOKEN(ifDebugTokenC) + IF_TOKEN(ifInfoTokenC) IF_TOKEN(ifWarningTokenC) IF_TOKEN(ifCriticalTokenC) IF_TOKEN(ifFatalTokenC) @@ -1055,6 +1215,9 @@ static void slog2_default_handler(QtMsgType msgType, const char *message) //Determines the severity level switch (msgType) { case QtDebugMsg: + severity = SLOG2_DEBUG1; + break; + case QtInfoMsg: severity = SLOG2_INFO; break; case QtWarningMsg: @@ -1117,6 +1280,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con } else if (token == typeTokenC) { switch (type) { case QtDebugMsg: message.append(QLatin1String("debug")); break; + case QtInfoMsg: message.append(QLatin1String("info")); break; case QtWarningMsg: message.append(QLatin1String("warning")); break; case QtCriticalMsg:message.append(QLatin1String("critical")); break; case QtFatalMsg: message.append(QLatin1String("fatal")); break; @@ -1139,6 +1303,9 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con } else if (token == appnameTokenC) { message.append(QCoreApplication::applicationName()); } else if (token == threadidTokenC) { + // print the TID as decimal + message.append(QString::number(qt_gettid())); + } else if (token == qthreadptrTokenC) { message.append(QLatin1String("0x")); message.append(QString::number(qlonglong(QThread::currentThread()->currentThread()), 16)); #ifdef QLOGGING_HAVE_BACKTRACE @@ -1201,6 +1368,12 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con if (pattern->timeFormat == QLatin1String("process")) { quint64 ms = pattern->timer.elapsed(); message.append(QString().sprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000))); + } else if (pattern->timeFormat == QLatin1String("boot")) { + // just print the milliseconds since the elapsed timer reference + // like the Linux kernel does + pattern->timer.elapsed(); + uint ms = pattern->timer.msecsSinceReference(); + message.append(QString().sprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000))); } else if (pattern->timeFormat.isEmpty()) { message.append(QDateTime::currentDateTime().toString(Qt::ISODate)); } else { @@ -1214,6 +1387,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con } else if (token == if##LEVEL##TokenC) { \ skip = type != Qt##LEVEL##Msg; HANDLE_IF_TOKEN(Debug) + HANDLE_IF_TOKEN(Info) HANDLE_IF_TOKEN(Warning) HANDLE_IF_TOKEN(Critical) HANDLE_IF_TOKEN(Fatal) @@ -1249,6 +1423,9 @@ static void systemd_default_message_handler(QtMsgType type, case QtDebugMsg: priority = LOG_DEBUG; // Debug-level messages break; + case QtInfoMsg: + priority = LOG_INFO; // Informational conditions + break; case QtWarningMsg: priority = LOG_WARNING; // Warning conditions break; @@ -1278,6 +1455,7 @@ static void android_default_message_handler(QtMsgType type, android_LogPriority priority = ANDROID_LOG_DEBUG; switch (type) { case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break; + case QtInfoMsg: priority = ANDROID_LOG_INFO; break; case QtWarningMsg: priority = ANDROID_LOG_WARN; break; case QtCriticalMsg: priority = ANDROID_LOG_ERROR; break; case QtFatalMsg: priority = ANDROID_LOG_FATAL; break; @@ -1548,9 +1726,13 @@ void qErrnoWarning(int code, const char *msg, ...) \row \li \c %{line} \li Line in source file \row \li \c %{message} \li The actual message \row \li \c %{pid} \li QCoreApplication::applicationPid() - \row \li \c %{threadid} \li ID of current thread + \row \li \c %{threadid} \li The system-wide ID of current thread (if it can be obtained) + \row \li \c %{qthreadptr} \li A pointer to the current QThread (result of QThread::currentThread()) \row \li \c %{type} \li "debug", "warning", "critical" or "fatal" \row \li \c %{time process} \li time of the message, in seconds since the process started (the token "process" is literal) + \row \li \c %{time boot} \li the time of the message, in seconds since the system boot if that + can be determined (the token "boot" is literal). If the time since boot could not be obtained, + the output is indeterminate (see QElapsedTimer::msecsSinceReference()). \row \li \c %{time [format]} \li system time when the message occurred, formatted by passing the \c format to \l QDateTime::toString(). If the format is not specified, the format of Qt::ISODate is used. @@ -1564,7 +1746,7 @@ void qErrnoWarning(int code, const char *msg, ...) tail call optimization. \endtable - You can also use conditionals on the type of the message using \c %{if-debug}, + You can also use conditionals on the type of the message using \c %{if-debug}, \c %{if-info} \c %{if-warning}, \c %{if-critical} or \c %{if-fatal} followed by an \c %{endif}. What is inside the \c %{if-*} and \c %{endif} will only be printed if the type matches. @@ -1573,7 +1755,7 @@ void qErrnoWarning(int code, const char *msg, ...) Example: \code - QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" + QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D{%endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" \endcode The default \a pattern is "%{if-category}%{category}: %{endif}%{message}". diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index f9bbf7fcce..0cbb678e17 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE class QDebug; class QNoDebug; -enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg }; +enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtInfoMsg, QtSystemMsg = QtCriticalMsg }; class QMessageLogContext { @@ -89,6 +89,7 @@ public: void debug(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); void noDebug(const char *, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3) {} + void info(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); @@ -96,6 +97,8 @@ public: void debug(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); void debug(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + void info(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + void info(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); void warning(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); void warning(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); void critical(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); @@ -110,6 +113,9 @@ public: QDebug debug() const; QDebug debug(const QLoggingCategory &cat) const; QDebug debug(CategoryFunction catFunc) const; + QDebug info() const; + QDebug info(const QLoggingCategory &cat) const; + QDebug info(CategoryFunction catFunc) const; QDebug warning() const; QDebug warning(const QLoggingCategory &cat) const; QDebug warning(CategoryFunction catFunc) const; @@ -143,20 +149,24 @@ private: #endif #define qDebug QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).debug +#define qInfo QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).info #define qWarning QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).warning #define qCritical QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).critical #define qFatal QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).fatal #define QT_NO_QDEBUG_MACRO while (false) QMessageLogger().noDebug -#define QT_NO_QWARNING_MACRO while (false) QMessageLogger().noDebug #if defined(QT_NO_DEBUG_OUTPUT) # undef qDebug # define qDebug QT_NO_QDEBUG_MACRO #endif +#if defined(QT_NO_INFO_OUTPUT) +# undef qInfo +# define qInfo QT_NO_QDEBUG_MACRO +#endif #if defined(QT_NO_WARNING_OUTPUT) # undef qWarning -# define qWarning QT_NO_QWARNING_MACRO +# define qWarning QT_NO_QDEBUG_MACRO #endif Q_CORE_EXPORT void qt_message_output(QtMsgType, const QMessageLogContext &context, diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index e239a11cda..5c7c435db8 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -42,6 +42,17 @@ QT_BEGIN_NAMESPACE +#if !defined(Q_QDOC) && !defined(Q_MOC_RUN) +struct QMetaObject; +const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT; // defined in qobject.h (which can't be included here) +#define QT_Q_ENUM(ENUM) \ + inline const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return qt_getQtMetaObject(); } \ + inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; } +#define QT_Q_FLAG(ENUM) QT_Q_ENUM(ENUM) +#else +#define QT_Q_ENUM Q_ENUM +#define QT_Q_FLAG Q_FLAG +#endif #ifndef Q_MOC_RUN namespace @@ -52,53 +63,6 @@ Qt { #if defined(Q_MOC_RUN) Q_OBJECT -#endif - -#if defined(Q_MOC_RUN) - // NOTE: Generally, do not add Q_ENUMS if a corresponding Q_FLAGS exists. - Q_ENUMS(ScrollBarPolicy FocusPolicy ContextMenuPolicy) - Q_ENUMS(ArrowType ToolButtonStyle PenStyle PenCapStyle PenJoinStyle BrushStyle) - Q_ENUMS(FillRule MaskMode BGMode ClipOperation SizeMode) - Q_ENUMS(Axis Corner Edge LayoutDirection SizeHint Orientation DropAction) - Q_FLAGS(Alignment Orientations DropActions Edges) - Q_FLAGS(DockWidgetAreas ToolBarAreas) - Q_ENUMS(DockWidgetArea ToolBarArea) - Q_ENUMS(TextFormat) - Q_ENUMS(TextElideMode) - Q_ENUMS(DateFormat TimeSpec DayOfWeek) - Q_ENUMS(CursorShape GlobalColor) - Q_ENUMS(AspectRatioMode TransformationMode) - Q_FLAGS(ImageConversionFlags) - Q_ENUMS(Key ShortcutContext) - Q_ENUMS(TextInteractionFlag) - Q_FLAGS(TextInteractionFlags) - Q_ENUMS(ItemSelectionMode) - Q_FLAGS(ItemFlags) - Q_ENUMS(CheckState) - Q_ENUMS(SortOrder CaseSensitivity) - Q_FLAGS(MatchFlags) - Q_FLAGS(KeyboardModifiers MouseButtons) - Q_ENUMS(WindowType WindowState WindowModality WidgetAttribute ApplicationAttribute) - Q_FLAGS(WindowFlags WindowStates) - Q_ENUMS(FocusReason) - Q_ENUMS(InputMethodHint InputMethodQuery) - Q_FLAGS(InputMethodHints InputMethodQueries) - Q_ENUMS(ScreenOrientation) - Q_FLAGS(ScreenOrientations) - Q_ENUMS(ConnectionType) - Q_ENUMS(ApplicationState) -#ifndef QT_NO_GESTURES - Q_ENUMS(GestureState) - Q_ENUMS(GestureType) - Q_ENUMS(NativeGestureType) -#endif - Q_ENUMS(CursorMoveStyle) - Q_ENUMS(TimerType) - Q_ENUMS(ScrollPhase) - Q_ENUMS(MouseEventSource) -#endif // defined(Q_MOC_RUN) - -#if defined(Q_MOC_RUN) public: #endif @@ -1298,6 +1262,11 @@ public: IntersectsItemBoundingRect = 0x3 }; + enum ItemSelectionOperation { + ReplaceSelection, + AddToSelection + }; + enum TransformationMode { FastTransformation, SmoothTransformation @@ -1469,7 +1438,8 @@ public: ItemIsUserCheckable = 16, ItemIsEnabled = 32, ItemIsTristate = 64, - ItemNeverHasChildren = 128 + ItemNeverHasChildren = 128, + ItemIsUserTristate = 256 }; Q_DECLARE_FLAGS(ItemFlags, ItemFlag) @@ -1637,11 +1607,95 @@ public: }; Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag) +#ifndef Q_QDOC + // NOTE: Generally, do not add QT_Q_ENUM if a corresponding Q_Q_FLAG exists. + QT_Q_ENUM(ScrollBarPolicy) + QT_Q_ENUM(FocusPolicy) + QT_Q_ENUM(ContextMenuPolicy) + QT_Q_ENUM(ArrowType) + QT_Q_ENUM(ToolButtonStyle) + QT_Q_ENUM(PenStyle) + QT_Q_ENUM(PenCapStyle) + QT_Q_ENUM(PenJoinStyle) + QT_Q_ENUM(BrushStyle) + QT_Q_ENUM(FillRule) + QT_Q_ENUM(MaskMode) + QT_Q_ENUM(BGMode) + QT_Q_ENUM(ClipOperation) + QT_Q_ENUM(SizeMode) + QT_Q_ENUM(Axis) + QT_Q_ENUM(Corner) + QT_Q_ENUM(Edge) + QT_Q_ENUM(LayoutDirection) + QT_Q_ENUM(SizeHint) + QT_Q_ENUM(Orientation) + QT_Q_ENUM(DropAction) + QT_Q_FLAG(Alignment) + QT_Q_FLAG(Orientations) + QT_Q_FLAG(DropActions) + QT_Q_FLAG(Edges) + QT_Q_FLAG(DockWidgetAreas) + QT_Q_FLAG(ToolBarAreas) + QT_Q_ENUM(DockWidgetArea) + QT_Q_ENUM(ToolBarArea) + QT_Q_ENUM(TextFormat) + QT_Q_ENUM(TextElideMode) + QT_Q_ENUM(DateFormat) + QT_Q_ENUM(TimeSpec) + QT_Q_ENUM(DayOfWeek) + QT_Q_ENUM(CursorShape) + QT_Q_ENUM(GlobalColor) + QT_Q_ENUM(AspectRatioMode) + QT_Q_ENUM(TransformationMode) + QT_Q_FLAG(ImageConversionFlags) + QT_Q_ENUM(Key) + QT_Q_ENUM(ShortcutContext) + QT_Q_ENUM(TextInteractionFlag) + QT_Q_FLAG(TextInteractionFlags) + QT_Q_ENUM(ItemSelectionMode) + QT_Q_ENUM(ItemSelectionOperation) + QT_Q_FLAG(ItemFlags) + QT_Q_ENUM(CheckState) + QT_Q_ENUM(SortOrder) + QT_Q_ENUM(CaseSensitivity) + QT_Q_FLAG(MatchFlags) + QT_Q_FLAG(KeyboardModifiers) + QT_Q_FLAG(MouseButtons) + QT_Q_ENUM(WindowType) + QT_Q_ENUM(WindowState) + QT_Q_ENUM(WindowModality) + QT_Q_ENUM(WidgetAttribute) + QT_Q_ENUM(ApplicationAttribute) + QT_Q_FLAG(WindowFlags) + QT_Q_FLAG(WindowStates) + QT_Q_ENUM(FocusReason) + QT_Q_ENUM(InputMethodHint) + QT_Q_ENUM(InputMethodQuery) + QT_Q_FLAG(InputMethodHints) + QT_Q_FLAG(InputMethodQueries) + QT_Q_ENUM(ScreenOrientation) + QT_Q_FLAG(ScreenOrientations) + QT_Q_ENUM(ConnectionType) + QT_Q_ENUM(ApplicationState) +#ifndef QT_NO_GESTURES + QT_Q_ENUM(GestureState) + QT_Q_ENUM(GestureType) + QT_Q_ENUM(NativeGestureType) +#endif + QT_Q_ENUM(CursorMoveStyle) + QT_Q_ENUM(TimerType) + QT_Q_ENUM(ScrollPhase) + QT_Q_ENUM(MouseEventSource) +#endif // Q_DOC + } #ifdef Q_MOC_RUN ; #endif +#undef QT_Q_ENUM +#undef QT_Q_FLAG + Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MouseButtons) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::Orientations) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::KeyboardModifiers) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 9e9a357272..e49bc1565f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2234,6 +2234,21 @@ */ /*! + \enum Qt::ItemSelectionOperation + + This enum is used in QGraphicsScene to specify what to do with currently selected + items when setting a selection area. + + \value ReplaceSelection The currently selected items are replaced by items + in the selection area. + + \value AddToSelection The items in the selection area are added to the currently + selected items. + + \sa QGraphicsScene::setSelectionArea() +*/ + +/*! \enum Qt::FillRule Specifies which method should be used to fill the paths and polygons. @@ -2559,8 +2574,13 @@ \value ItemIsDropEnabled It can be used as a drop target. \value ItemIsUserCheckable It can be checked or unchecked by the user. \value ItemIsEnabled The user can interact with the item. - \value ItemIsTristate The item is checkable with three separate states. + \value ItemIsTristate The item can show three separate states. + This enables automatic management of the state of parent items in QTreeWidget + (checked if all children are checked, unchecked if all children are unchecked, + or partially checked if only some children are checked). \value ItemNeverHasChildren The item never has child items. + \value ItemIsUserTristate The user can cycle through three separate states. + This value has been added in Qt 5.5. Note that checkable items need to be given both a suitable set of flags and an initial state, indicating whether the item is checked or not. diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index 277caa8db6..e80720ae67 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -72,8 +72,9 @@ public: # endif }; #endif -#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) enum WinVersion { + WV_None = 0x0000, + WV_32s = 0x0001, WV_95 = 0x0002, WV_98 = 0x0003, @@ -89,6 +90,7 @@ public: WV_WINDOWS7 = 0x0090, WV_WINDOWS8 = 0x00a0, WV_WINDOWS8_1 = 0x00b0, + WV_WINDOWS10 = 0x00c0, WV_NT_based = 0x00f0, /* version numbers */ @@ -100,6 +102,7 @@ public: WV_6_1 = WV_WINDOWS7, WV_6_2 = WV_WINDOWS8, WV_6_3 = WV_WINDOWS8_1, + WV_10_0 = WV_WINDOWS10, WV_CE = 0x0100, WV_CENET = 0x0200, @@ -107,13 +110,18 @@ public: WV_CE_6 = 0x0400, WV_CE_based = 0x0f00 }; +#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) static const WinVersion WindowsVersion; static WinVersion windowsVersion(); - +#else + static const WinVersion WindowsVersion = WV_None; + static WinVersion windowsVersion() { return WV_None; } #endif -#ifdef Q_OS_MAC -# define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) + +#define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) +#define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) enum MacVersion { + MV_None = 0xffff, MV_Unknown = 0x0000, /* version */ @@ -154,8 +162,12 @@ public: MV_IOS_7_1 = Q_MV_IOS(7, 1), MV_IOS_8_0 = Q_MV_IOS(8, 0) }; +#if defined(Q_OS_MAC) static const MacVersion MacintoshVersion; static MacVersion macVersion(); +#else + static const MacVersion MacintoshVersion = MV_None; + static MacVersion macVersion() { return MV_None; } #endif static QString buildCpuArchitecture(); diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 08a5daa5f4..37d571e228 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -75,6 +75,7 @@ BSD4 - Any BSD 4.4 system UNIX - Any UNIX BSD/SYSV system ANDROID - Android platform + HAIKU - Haiku The following operating systems have variants: LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android @@ -169,6 +170,8 @@ # define Q_OS_INTEGRITY #elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */ # define Q_OS_VXWORKS +#elif defined(__HAIKU__) +# define Q_OS_HAIKU #elif defined(__MAKEDEPEND__) #else # error "Qt has not been ported to this OS - see http://www.qt-project.org/" diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index e5abb8138b..e2b165ccbc 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -202,19 +202,12 @@ Q_DECLARE_TYPEINFO_BODY(QFlags<T>, Q_PRIMITIVE_TYPE); types must define a member-swap, and be defined in the same namespace as Qt for this to work. */ -#define Q_DECLARE_SHARED_STL(TYPE) \ -QT_END_NAMESPACE \ -namespace std { \ - template<> inline void swap< QT_PREPEND_NAMESPACE(TYPE) >(QT_PREPEND_NAMESPACE(TYPE) &value1, QT_PREPEND_NAMESPACE(TYPE) &value2) \ - { value1.swap(value2); } \ -} \ -QT_BEGIN_NAMESPACE #define Q_DECLARE_SHARED(TYPE) \ Q_DECLARE_TYPEINFO(TYPE, Q_MOVABLE_TYPE); \ -template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ -{ value1.swap(value2); } \ -Q_DECLARE_SHARED_STL(TYPE) +inline void swap(TYPE &value1, TYPE &value2) \ + Q_DECL_NOEXCEPT_EXPR(noexcept(value1.swap(value2))) \ +{ value1.swap(value2); } /* QTypeInfo primitive specializations |