summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-02-19 10:06:25 +0100
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-02-19 10:06:25 +0100
commit30fd22b9574def54726e7b193127cc0c901c1b4c (patch)
tree96dfc923044db0515064ba39d052d9ed577e3e40 /src/corelib/global
parentd7b0581c1c2ef60c08d238dae39298af6904918f (diff)
parent6aa09bbce59828d028f6d1e81d2bfc6ba537aae1 (diff)
Merge remote-tracking branch 'origin/dev' into stable
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/global.pri6
-rw-r--r--src/corelib/global/qcompilerdetection.h81
-rw-r--r--src/corelib/global/qflags.h12
-rw-r--r--src/corelib/global/qglobal.cpp43
-rw-r--r--src/corelib/global/qglobal.h42
-rw-r--r--src/corelib/global/qlibraryinfo.cpp108
-rw-r--r--src/corelib/global/qlibraryinfo.h6
-rw-r--r--src/corelib/global/qlogging.cpp327
-rw-r--r--src/corelib/global/qlogging.h17
-rw-r--r--src/corelib/global/qnamespace.h35
-rw-r--r--src/corelib/global/qnamespace.qdoc82
-rw-r--r--src/corelib/global/qnumeric.cpp136
-rw-r--r--src/corelib/global/qnumeric.h3
-rw-r--r--src/corelib/global/qprocessordetection.h20
-rw-r--r--src/corelib/global/qtypeinfo.h17
15 files changed, 885 insertions, 50 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index fd031469f6..789f500cab 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -51,3 +51,9 @@ slog2 {
LIBS_PRIVATE += -lslog2
DEFINES += QT_USE_SLOG2
}
+
+journald {
+ CONFIG += link_pkgconfig
+ PKGCONFIG_PRIVATE += libsystemd-journal
+ DEFINES += QT_USE_JOURNALD
+}
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index d526d40398..70f45345c6 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -98,6 +98,7 @@
# define Q_UNREACHABLE_IMPL() __assume(0)
# define Q_NORETURN __declspec(noreturn)
# define Q_DECL_DEPRECATED __declspec(deprecated)
+# define Q_DECL_DEPRECATED_X(text) __declspec(deprecated(text))
# define Q_DECL_EXPORT __declspec(dllexport)
# define Q_DECL_IMPORT __declspec(dllimport)
/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
@@ -152,6 +153,9 @@
# define Q_CC_INTEL
# define Q_ASSUME_IMPL(expr) __assume(expr)
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
+# if __INTEL_COMPILER >= 1300 && !defined(__APPLE__)
+# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
+# endif
# elif defined(__clang__)
/* Clang also masquerades as GCC */
# define Q_CC_CLANG
@@ -173,6 +177,7 @@
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
+# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
# endif
# endif
@@ -469,12 +474,29 @@
* N2544 Q_COMPILER_UNRESTRICTED_UNIONS
* N1653 Q_COMPILER_VARIADIC_MACROS
* N2242 N2555 Q_COMPILER_VARIADIC_TEMPLATES
+ *
+ * C++1y proposed features
+ *
+ * N3472 Q_COMPILER_BINARY_LITERALS
+ * N3649 Q_COMPILER_GENERIC_LAMBDA
+ * N3638 Q_COMPILER_LAMBDA_CAPTURES
+ * N3652 Q_COMPILER_RELAXED_CONSTEXPR_FUNCTIONS
+ * N3386 N3638 Q_COMPILER_RETURN_TYPE_DEDUCTION
+ * N3651 Q_COMPILER_VARIABLE_TEMPLATES
+ * N3639 Q_COMPILER_VLA (see also Q_COMPILER_RESTRICTED_VLA)
+ *
*/
#ifdef Q_CC_INTEL
+# define Q_COMPILER_RESTRICTED_VLA
# if __INTEL_COMPILER < 1200
# define Q_NO_TEMPLATE_FRIENDS
# endif
+# if __INTEL_COMPILER >= 1310 && !defined(_WIN32)
+// ICC supports C++14 binary literals in C, C++98, and C++11 modes
+// at least since 13.1, but I can't test further back
+# define Q_COMPILER_BINARY_LITERALS
+# endif
# if __cplusplus >= 201103L
# define Q_COMPILER_VARIADIC_MACROS
# if __INTEL_COMPILER >= 1200
@@ -487,7 +509,6 @@
# define Q_COMPILER_LAMBDA
# define Q_COMPILER_RVALUE_REFS
# define Q_COMPILER_STATIC_ASSERT
-# define Q_COMPILER_THREAD_LOCAL
# define Q_COMPILER_VARIADIC_MACROS
# endif
# if __INTEL_COMPILER >= 1210
@@ -518,8 +539,9 @@
# endif
#endif
-#ifdef Q_CC_CLANG
+#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
/* General C++ features */
+# define Q_COMPILER_RESTRICTED_VLA
# if !__has_feature(cxx_exceptions)
# ifndef QT_NO_EXCEPTIONS
# define QT_NO_EXCEPTIONS
@@ -528,6 +550,15 @@
# if !__has_feature(cxx_rtti)
# define QT_NO_RTTI
# endif
+# if __has_feature(attribute_deprecated_with_message)
+# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
+# endif
+
+// Clang supports binary literals in C, C++98 and C++11 modes
+// It's been supported "since the dawn of time itself" (cf. commit 179883)
+# if __has_extension(cxx_binary_literals)
+# define Q_COMPILER_BINARY_LITERALS
+# endif
/* C++11 features, see http://clang.llvm.org/cxx_status.html */
# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
@@ -628,9 +659,40 @@
# define Q_COMPILER_VARIADIC_MACROS
# endif
# endif
+
+/* C++1y features, see http://clang.llvm.org/cxx_status.html and
+ * http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-standard-language-features */
+# if __cplusplus > 201103L
+//# if __has_feature(cxx_binary_literals)
+//# define Q_COMPILER_BINARY_LITERALS // see above
+//# endif
+# if __has_feature(cxx_generic_lambda)
+# define Q_COMPILER_GENERIC_LAMBDA
+# endif
+# if __has_feature(cxx_init_capture)
+# define Q_COMPILER_LAMBDA_CAPTURES
+# endif
+# if __has_feature(cxx_relaxed_constexpr)
+# define Q_COMPILER_RELAXED_CONSTEXPR_FUNCTIONS
+# endif
+# if __has_feature(cxx_decltype_auto) && __has_feature(cxx_return_type_deduction)
+# define Q_COMPILER_RETURN_TYPE_DEDUCTION
+# endif
+# if __has_feature(cxx_variable_templates)
+# define Q_COMPILER_VARIABLE_TEMPLATES
+# endif
+# if __has_feature(cxx_runtime_array)
+# define Q_COMPILER_VLA
+# endif
+# endif
#endif // Q_CC_CLANG
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
+# define Q_COMPILER_RESTRICTED_VLA
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
+// GCC supports binary literals in C, C++98 and C++11 modes
+# define Q_COMPILER_BINARY_LITERALS
+# endif
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
/* C++11 features supported in GCC 4.3: */
@@ -693,6 +755,15 @@
# endif
/* C++11 features are complete as of GCC 4.8.1 */
# endif
+# if __cplusplus > 201103L
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409
+ /* C++1y features in GCC 4.9 */
+//# define Q_COMPILER_BINARY_LITERALS // already supported since GCC 4.3 as an extension
+# define Q_COMPILER_LAMBDA_CAPTURES
+# define Q_COMPILER_RETURN_TYPE_DEDUCTION
+# define Q_COMPILER_VLA
+# endif
+# endif
#endif
#if defined(Q_CC_MSVC) && !defined(Q_CC_INTEL)
@@ -796,8 +867,10 @@
#ifdef Q_COMPILER_CONSTEXPR
# define Q_DECL_CONSTEXPR constexpr
+# define Q_CONSTEXPR constexpr
#else
# define Q_DECL_CONSTEXPR
+# define Q_CONSTEXPR const
#endif
#ifdef Q_COMPILER_EXPLICIT_OVERRIDES
@@ -861,6 +934,9 @@
#ifndef Q_DECL_VARIABLE_DEPRECATED
# define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
#endif
+#ifndef Q_DECL_DEPRECATED_X
+# define Q_DECL_DEPRECATED_X(text) Q_DECL_DEPRECATED
+#endif
#ifndef Q_DECL_EXPORT
# define Q_DECL_EXPORT
#endif
@@ -943,7 +1019,6 @@
#endif
#if !defined(Q_PROCESSOR_ARM)
# undef QT_COMPILER_SUPPORTS_IWMMXT
-# undef QT_COMPILER_SUPPORTS_NEON
#endif
#if !defined(Q_PROCESSOR_MIPS)
# undef QT_COMPILER_SUPPORTS_MIPS_DSP
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index dd4222b89f..9e97724fec 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -53,13 +53,19 @@ class QFlag
{
int i;
public:
- Q_DECL_CONSTEXPR inline QFlag(int i);
+#if !defined(__LP64__) && !defined(Q_QDOC)
+ Q_DECL_CONSTEXPR inline QFlag(long ai) : i(int(ai)) {}
+ Q_DECL_CONSTEXPR inline QFlag(ulong ai) : i(int(long(ai))) {}
+#endif
+ Q_DECL_CONSTEXPR inline QFlag(int ai) : i(ai) {}
+ Q_DECL_CONSTEXPR inline QFlag(uint ai) : i(int(ai)) {}
+ Q_DECL_CONSTEXPR inline QFlag(short ai) : i(int(ai)) {}
+ Q_DECL_CONSTEXPR inline QFlag(ushort ai) : i(int(uint(ai))) {}
Q_DECL_CONSTEXPR inline operator int() const { return i; }
+ Q_DECL_CONSTEXPR inline operator uint() const { return uint(i); }
};
Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE);
-Q_DECL_CONSTEXPR inline QFlag::QFlag(int ai) : i(ai) {}
-
class QIncompatibleFlag
{
int i;
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index a9f6df6291..fe10c493a7 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -115,12 +115,40 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
*/
/*!
+ \fn QFlag::QFlag(uint value)
+ \since Qt 5.3
+
+ Constructs a QFlag object that stores the given \a value.
+*/
+
+/*!
+ \fn QFlag::QFlag(short value)
+ \since 5.3
+
+ Constructs a QFlag object that stores the given \a value.
+*/
+
+/*!
+ \fn QFlag::QFlag(ushort value)
+ \since Qt 5.3
+
+ Constructs a QFlag object that stores the given \a value.
+*/
+
+/*!
\fn QFlag::operator int() const
Returns the value stored by the QFlag object.
*/
/*!
+ \fn QFlag::operator uint() const
+ \since Qt 5.3
+
+ Returns the value stored by the QFlag object.
+*/
+
+/*!
\class QFlags
\inmodule QtCore
\brief The QFlags class provides a type-safe way of storing
@@ -2186,7 +2214,9 @@ QString qt_error_string(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN)
+ // Retrieve the system error message for the last-error code.
+# ifndef Q_OS_WINRT
wchar_t *string = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
@@ -2197,6 +2227,17 @@ QString qt_error_string(int errorCode)
NULL);
ret = QString::fromWCharArray(string);
LocalFree((HLOCAL)string);
+# else // !Q_OS_WINRT
+ __declspec(thread) static wchar_t errorString[4096];
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ errorCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ errorString,
+ ARRAYSIZE(errorString),
+ NULL);
+ ret = QString::fromWCharArray(errorString);
+# endif // Q_OS_WINRT
if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
ret = QString::fromLatin1("The specified module could not be found.");
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index cd7899021d..b2f9e29b44 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -45,11 +45,11 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.2.2"
+#define QT_VERSION_STR "5.3.0"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050202
+#define QT_VERSION 0x050300
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
@@ -191,7 +191,7 @@ typedef qint64 qlonglong;
typedef quint64 qulonglong;
#ifndef QT_POINTER_SIZE
-# if defined(Q_OS_WIN64)
+# if defined(Q_OS_WIN64) || (defined(Q_OS_WINRT) && defined(_M_X64))
# define QT_POINTER_SIZE 8
# elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
# define QT_POINTER_SIZE 4
@@ -221,11 +221,14 @@ typedef double qreal;
#if defined(QT_NO_DEPRECATED)
# undef QT_DEPRECATED
+# undef QT_DEPRECATED_X
# undef QT_DEPRECATED_VARIABLE
# undef QT_DEPRECATED_CONSTRUCTOR
#elif defined(QT_DEPRECATED_WARNINGS)
# undef QT_DEPRECATED
# define QT_DEPRECATED Q_DECL_DEPRECATED
+# undef QT_DEPRECATED_X
+# define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
# undef QT_DEPRECATED_VARIABLE
# define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED
# undef QT_DEPRECATED_CONSTRUCTOR
@@ -233,6 +236,8 @@ typedef double qreal;
#else
# undef QT_DEPRECATED
# define QT_DEPRECATED
+# undef QT_DEPRECATED_X
+# define QT_DEPRECATED_X(text)
# undef QT_DEPRECATED_VARIABLE
# define QT_DEPRECATED_VARIABLE
# undef QT_DEPRECATED_CONSTRUCTOR
@@ -432,6 +437,8 @@ template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qin
template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
+typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
+typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
typedef QIntegerForSizeof<void*>::Unsigned quintptr;
typedef QIntegerForSizeof<void*>::Signed qptrdiff;
typedef qptrdiff qintptr;
@@ -527,12 +534,12 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
#ifdef Q_OS_DARWIN
# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \
- (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \
- (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios)
+ ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \
+ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios))
# define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) \
- (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < osx) || \
- (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios)
+ ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < osx) || \
+ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios))
# define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) \
QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios)
@@ -559,7 +566,12 @@ class QDataStream;
#endif
#if defined(Q_OS_WINRT)
+# define QT_NO_FILESYSTEMWATCHER
+# define QT_NO_GETADDRINFO
+# define QT_NO_NETWORKPROXY
# define QT_NO_PROCESS
+# define QT_NO_SOCKETNOTIFIER
+# define QT_NO_SOCKS5
#endif
inline void qt_noop(void) {}
@@ -1017,6 +1029,9 @@ namespace QtPrivate {
//like std::enable_if
template <bool B, typename T = void> struct QEnableIf;
template <typename T> struct QEnableIf<true, T> { typedef T Type; };
+
+template <bool B, typename T, typename F> struct QConditional { typedef T Type; };
+template <typename T, typename F> struct QConditional<false, T, F> { typedef F Type; };
}
#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
@@ -1034,14 +1049,17 @@ template <typename T> struct QEnableIf<true, T> { typedef T Type; };
#endif
QT_END_NAMESPACE
-// Q_GLOBAL_STATIC
-#include <QtCore/qglobalstatic.h>
-// qDebug and friends
+// We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4.
+// Be careful when changing the order of these files.
+#include <QtCore/qtypeinfo.h>
+#include <QtCore/qsysinfo.h>
#include <QtCore/qlogging.h>
+
#include <QtCore/qflags.h>
-#include <QtCore/qsysinfo.h>
-#include <QtCore/qtypeinfo.h>
+
+#include <QtCore/qatomic.h>
+#include <QtCore/qglobalstatic.h>
#include <QtCore/qnumeric.h>
#endif /* __cplusplus */
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 1c3b09f602..ed1715ddb5 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qdir.h"
+#include "qstringlist.h"
#include "qfile.h"
#include "qsettings.h"
#include "qlibraryinfo.h"
@@ -113,6 +114,8 @@ public:
}
};
+static const char platformsSection[] = "Platforms";
+
QLibrarySettings::QLibrarySettings()
: settings(QLibraryInfoPrivate::findConfiguration())
{
@@ -132,7 +135,8 @@ QLibrarySettings::QLibrarySettings()
haveEffectivePaths = children.contains(QLatin1String("EffectivePaths"));
#endif
// Backwards compat: an existing but empty file is claimed to contain the Paths section.
- havePaths = !haveEffectivePaths || children.contains(QLatin1String("Paths"));
+ havePaths = (!haveEffectivePaths && !children.contains(QLatin1String(platformsSection)))
+ || children.contains(QLatin1String("Paths"));
#ifndef QT_BOOTSTRAPPED
if (!havePaths)
settings.reset(0);
@@ -156,23 +160,23 @@ QSettings *QLibraryInfoPrivate::findConfiguration()
#else
if (!QFile::exists(qtconfig) && QCoreApplication::instance()) {
#ifdef Q_OS_MAC
- CFBundleRef bundleRef = CFBundleGetMainBundle();
+ CFBundleRef bundleRef = CFBundleGetMainBundle();
if (bundleRef) {
- QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef,
- QCFString(QLatin1String("qt.conf")),
- 0,
- 0);
- if (urlRef) {
- QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
- qtconfig = QDir::cleanPath(path);
- }
- }
- if (qtconfig.isEmpty())
+ QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef,
+ QCFString(QLatin1String("qt.conf")),
+ 0,
+ 0);
+ if (urlRef) {
+ QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
+ qtconfig = QDir::cleanPath(path);
+ }
+ }
+ if (qtconfig.isEmpty())
#endif
{
QDir pwd(QCoreApplication::applicationDirPath());
qtconfig = pwd.filePath(QLatin1String("qt.conf"));
- }
+ }
}
#endif
if (QFile::exists(qtconfig))
@@ -251,6 +255,57 @@ QLibraryInfo::buildDate()
}
#endif //QT_NO_DATESTRING
+#if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too
+# ifdef __apple_build_version__ // Apple clang has other version numbers
+# define COMPILER_STRING __clang_version__ " (Apple)"
+# else
+# define COMPILER_STRING __clang_version__
+# endif
+#elif defined(Q_CC_GNU)
+# define COMPILER_STRING "GCC " __VERSION__
+#elif defined(Q_CC_MSVC)
+# if _MSC_VER < 1600
+# define COMPILER_STRING "MSVC 2008"
+# elif _MSC_VER < 1700
+# define COMPILER_STRING "MSVC 2010"
+# elif _MSC_VER < 1800
+# define COMPILER_STRING "MSVC 2012"
+# elif _MSC_VER < 1900
+# define COMPILER_STRING "MSVC 2013"
+# else
+# define COMPILER_STRING "MSVC <unknown version>"
+# endif
+#else
+# define COMPILER_STRING "<unknown compiler>"
+#endif
+
+/*!
+ Returns a string describing how this version of Qt was built.
+
+ \internal
+
+ \since 5.3
+*/
+
+const char *QLibraryInfo::build()
+{
+ static const char data[] = "Qt " QT_VERSION_STR " (" __DATE__ "), "
+ COMPILER_STRING ", "
+#if QT_POINTER_SIZE == 4
+ "32"
+#else
+ "64"
+#endif
+ " bit, "
+#ifdef QT_NO_DEBUG
+ "release"
+#else
+ "debug"
+#endif
+ " build)";
+ return data;
+}
+
/*!
\since 5.0
Returns \c true if this build of Qt was built with debugging enabled, or
@@ -466,6 +521,33 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
}
/*!
+ Returns additional arguments to the platform plugin matching
+ \a platformName which can be specified as a string list using
+ the key \c Arguments in a group called \c Platforms of the
+ \c qt.conf file.
+
+ sa {Using qt.conf}
+
+ \internal
+
+ \since 5.3
+*/
+
+QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
+{
+#ifndef QT_BOOTSTRAPPED
+ if (const QSettings *settings = QLibraryInfoPrivate::findConfiguration()) {
+ QString key = QLatin1String(platformsSection);
+ key += QLatin1Char('/');
+ key += platformName;
+ key += QLatin1String("Arguments");
+ return settings->value(key).toStringList();
+ }
+#endif // !QT_BOOTSTRAPPED
+ return QStringList();
+}
+
+/*!
\enum QLibraryInfo::LibraryLocation
\keyword library location
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 17864b555b..2a8a3b84b9 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
+class QStringList;
+
class Q_CORE_EXPORT QLibraryInfo
{
public:
@@ -57,6 +59,8 @@ public:
static QDate buildDate();
#endif //QT_NO_DATESTRING
+ static const char * build();
+
static bool isDebugBuild();
enum LibraryLocation
@@ -96,6 +100,8 @@ public:
static QString rawLocation(LibraryLocation, PathGroup);
#endif
+ static QStringList platformPluginArguments(const QString &platformName);
+
private:
QLibraryInfo();
};
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index cff8846cdc..64dd544cf0 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -46,10 +46,10 @@
#include "qvarlengtharray.h"
#include "qdebug.h"
#include "qmutex.h"
+#include "qloggingcategory.h"
#ifndef QT_BOOTSTRAPPED
#include "qcoreapplication.h"
#include "qthread.h"
-#include "qloggingcategory.h"
#include "private/qloggingregistry_p.h"
#endif
#ifdef Q_OS_WIN
@@ -63,6 +63,11 @@
#include <android/log.h>
#endif
+#if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
+# include <systemd/sd-journal.h>
+# include <unistd.h>
+#endif
+
#include <stdio.h>
QT_BEGIN_NAMESPACE
@@ -265,6 +270,76 @@ void QMessageLogger::debug(const char *msg, ...) const
qt_message_fatal(QtDebugMsg, context, message);
}
+/*!
+ \typedef QMessageLogger::CategoryFunction
+
+ This is a typedef for a pointer to a function with the following
+ signature:
+
+ \snippet code/qlogging/qlogging.cpp 2
+
+ A function which this signature is generated by Q_DECLARE_LOGGING_CATEGORY,
+ Q_LOGGING_CATEGORY.
+
+ \since 5.3
+*/
+
+/*!
+ Logs a debug message specified with format \a msg for the context \a cat.
+ Additional parameters, specified by \a msg, may be used.
+
+ \since 5.3
+ \sa qCDebug()
+*/
+void QMessageLogger::debug(const QLoggingCategory &cat, const char *msg, ...) const
+{
+ if (!cat.isDebugEnabled())
+ 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(QtDebugMsg, ctxt, msg, ap, message);
+ va_end(ap);
+
+ if (isFatal(QtDebugMsg))
+ qt_message_fatal(QtDebugMsg, ctxt, message);
+}
+
+/*!
+ Logs a debug message specified with format \a msg for the context returned
+ by \a catFunc. Additional parameters, specified by \a msg, may be used.
+
+ \since 5.3
+ \sa qCDebug()
+*/
+void QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc,
+ const char *msg, ...) const
+{
+ const QLoggingCategory &cat = (*catFunc)();
+ if (!cat.isDebugEnabled())
+ 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(QtDebugMsg, ctxt, msg, ap, message);
+ va_end(ap);
+
+ if (isFatal(QtDebugMsg))
+ qt_message_fatal(QtDebugMsg, ctxt, message);
+}
+
#ifndef QT_NO_DEBUG_STREAM
/*!
@@ -281,6 +356,36 @@ QDebug QMessageLogger::debug() const
}
/*!
+ Logs a debug message into category \a cat using a QDebug stream.
+
+ \since 5.3
+ \sa qCDebug(), QDebug
+*/
+QDebug QMessageLogger::debug(const QLoggingCategory &cat) const
+{
+ QDebug dbg = QDebug(QtDebugMsg);
+ if (!cat.isDebugEnabled())
+ dbg.stream->message_output = false;
+
+ QMessageLogContext &ctxt = dbg.stream->context;
+ ctxt.copy(context);
+ ctxt.category = cat.categoryName();
+
+ return dbg;
+}
+
+/*!
+ Logs a debug message into category returned by \a catFunc using a QDebug stream.
+
+ \since 5.3
+ \sa qCDebug(), QDebug
+*/
+QDebug QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc) const
+{
+ return debug((*catFunc)());
+}
+
+/*!
\internal
Returns a QNoDebug object, which is used to ignore debugging output.
@@ -314,9 +419,65 @@ void QMessageLogger::warning(const char *msg, ...) const
qt_message_fatal(QtWarningMsg, context, message);
}
+/*!
+ Logs a warning message specified with format \a msg for the context \a cat.
+ Additional parameters, specified by \a msg, may be used.
+
+ \since 5.3
+ \sa qCWarning()
+*/
+void QMessageLogger::warning(const QLoggingCategory &cat, const char *msg, ...) const
+{
+ if (!cat.isWarningEnabled())
+ 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(QtWarningMsg, ctxt, msg, ap, message);
+ va_end(ap);
+
+ if (isFatal(QtWarningMsg))
+ qt_message_fatal(QtWarningMsg, ctxt, message);
+}
+
+/*!
+ Logs a warning message specified with format \a msg for the context returned
+ by \a catFunc. Additional parameters, specified by \a msg, may be used.
+
+ \since 5.3
+ \sa qCWarning()
+*/
+void QMessageLogger::warning(QMessageLogger::CategoryFunction catFunc,
+ const char *msg, ...) const
+{
+ const QLoggingCategory &cat = (*catFunc)();
+ if (!cat.isWarningEnabled())
+ 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(QtWarningMsg, ctxt, msg, ap, message);
+ va_end(ap);
+
+ if (isFatal(QtWarningMsg))
+ qt_message_fatal(QtWarningMsg, ctxt, message);
+}
+
#ifndef QT_NO_DEBUG_STREAM
/*!
- Logs a debug message using a QDebug stream
+ Logs a warning message using a QDebug stream
\sa qWarning(), QDebug
*/
@@ -327,6 +488,36 @@ QDebug QMessageLogger::warning() const
ctxt.copy(context);
return dbg;
}
+
+/*!
+ Logs a warning message into category \a cat using a QDebug stream.
+
+ \sa qCWarning(), QDebug
+*/
+QDebug QMessageLogger::warning(const QLoggingCategory &cat) const
+{
+ QDebug dbg = QDebug(QtWarningMsg);
+ if (!cat.isWarningEnabled())
+ dbg.stream->message_output = false;
+
+ QMessageLogContext &ctxt = dbg.stream->context;
+ ctxt.copy(context);
+ ctxt.category = cat.categoryName();
+
+ return dbg;
+}
+
+/*!
+ Logs a warning message into category returned by \a catFunc using a QDebug stream.
+
+ \since 5.3
+ \sa qCWarning(), QDebug
+*/
+QDebug QMessageLogger::warning(QMessageLogger::CategoryFunction catFunc) const
+{
+ return warning((*catFunc)());
+}
+
#endif
#undef qCritical
@@ -350,6 +541,62 @@ void QMessageLogger::critical(const char *msg, ...) const
qt_message_fatal(QtCriticalMsg, context, message);
}
+/*!
+ Logs a critical message specified with format \a msg for the context \a cat.
+ Additional parameters, specified by \a msg, may be used.
+
+ \since 5.3
+ \sa qCCritical()
+*/
+void QMessageLogger::critical(const QLoggingCategory &cat, const char *msg, ...) const
+{
+ if (!cat.isCriticalEnabled())
+ 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(QtCriticalMsg, ctxt, msg, ap, message);
+ va_end(ap);
+
+ if (isFatal(QtCriticalMsg))
+ qt_message_fatal(QtCriticalMsg, ctxt, message);
+}
+
+/*!
+ Logs a critical message specified with format \a msg for the context returned
+ by \a catFunc. Additional parameters, specified by \a msg, may be used.
+
+ \since 5.3
+ \sa qCCritical()
+*/
+void QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc,
+ const char *msg, ...) const
+{
+ const QLoggingCategory &cat = (*catFunc)();
+ if (!cat.isCriticalEnabled())
+ 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(QtCriticalMsg, ctxt, msg, ap, message);
+ va_end(ap);
+
+ if (isFatal(QtCriticalMsg))
+ qt_message_fatal(QtCriticalMsg, ctxt, message);
+}
+
#ifndef QT_NO_DEBUG_STREAM
/*!
Logs a critical message using a QDebug stream
@@ -363,6 +610,37 @@ QDebug QMessageLogger::critical() const
ctxt.copy(context);
return dbg;
}
+
+/*!
+ Logs a critical message into category \a cat using a QDebug stream.
+
+ \since 5.3
+ \sa qCCritical(), QDebug
+*/
+QDebug QMessageLogger::critical(const QLoggingCategory &cat) const
+{
+ QDebug dbg = QDebug(QtCriticalMsg);
+ if (!cat.isCriticalEnabled())
+ dbg.stream->message_output = false;
+
+ QMessageLogContext &ctxt = dbg.stream->context;
+ ctxt.copy(context);
+ ctxt.category = cat.categoryName();
+
+ return dbg;
+}
+
+/*!
+ Logs a critical message into category returned by \a catFunc using a QDebug stream.
+
+ \since 5.3
+ \sa qCCritical(), QDebug
+*/
+QDebug QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc) const
+{
+ return critical((*catFunc)());
+}
+
#endif
#undef qFatal
@@ -866,12 +1144,43 @@ Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
static QtMsgHandler msgHandler = 0; // pointer to debug handler (without context)
static QtMessageHandler messageHandler = 0; // pointer to debug handler (with context)
+#if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
+static void systemd_default_message_handler(QtMsgType type,
+ const QMessageLogContext &context,
+ const QString &message)
+{
+ int priority = LOG_INFO; // Informational
+ switch (type) {
+ case QtDebugMsg:
+ priority = LOG_DEBUG; // Debug-level messages
+ break;
+ case QtWarningMsg:
+ priority = LOG_WARNING; // Warning conditions
+ break;
+ case QtCriticalMsg:
+ priority = LOG_CRIT; // Critical conditions
+ break;
+ case QtFatalMsg:
+ priority = LOG_ALERT; // Action must be taken immediately
+ break;
+ }
+
+ char filebuf[PATH_MAX + sizeof("CODE_FILE=")];
+ snprintf(filebuf, sizeof(filebuf), "CODE_FILE=%s", context.file ? context.file : "unknown");
+
+ char linebuf[20];
+ snprintf(linebuf, sizeof(linebuf), "CODE_LINE=%d", context.line);
+
+ sd_journal_print_with_location(priority, filebuf, linebuf, context.function ? context.function : "unknown", "%s", message.toUtf8().constData());
+}
+#endif
+
#ifdef Q_OS_ANDROID
static void android_default_message_handler(QtMsgType type,
const QMessageLogContext &context,
const QString &message)
{
- android_LogPriority priority;
+ android_LogPriority priority = ANDROID_LOG_DEBUG;
switch (type) {
case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break;
case QtWarningMsg: priority = ANDROID_LOG_WARN; break;
@@ -902,6 +1211,18 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
#if defined(QT_USE_SLOG2)
slog2_default_handler(type, logMessage.toLocal8Bit().constData());
+#elif defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
+ // We use isatty to catch the obvious case of someone running something interactively.
+ // We also support an environment variable for Qt Creator use, or more complicated cases like subprocesses.
+ static bool logToConsole = isatty(fileno(stdin)) || !qEnvironmentVariableIsEmpty("QT_NO_JOURNALD_LOG");
+ if (Q_LIKELY(!logToConsole)) {
+ // remove trailing \n, systemd appears to want them newline-less
+ logMessage.chop(1);
+ systemd_default_message_handler(type, context, logMessage);
+ } else {
+ fprintf(stderr, "%s", logMessage.toUtf8().constData());
+ fflush(stderr);
+ }
#elif defined(Q_OS_ANDROID)
static bool logToAndroid = qEnvironmentVariableIsEmpty("QT_ANDROID_PLAIN_LOG");
if (logToAndroid) {
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index 5ae1fb3205..6ebffa3ba1 100644
--- a/src/corelib/global/qlogging.h
+++ b/src/corelib/global/qlogging.h
@@ -82,6 +82,8 @@ private:
friend class QDebug;
};
+class QLoggingCategory;
+
class Q_CORE_EXPORT QMessageLogger
{
Q_DISABLE_COPY(QMessageLogger)
@@ -98,6 +100,15 @@ public:
void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
+ typedef const QLoggingCategory &(*CategoryFunction)();
+
+ 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 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);
+ void critical(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
+
#ifndef Q_CC_MSVC
Q_NORETURN
#endif
@@ -105,8 +116,14 @@ public:
#ifndef QT_NO_DEBUG_STREAM
QDebug debug() const;
+ QDebug debug(const QLoggingCategory &cat) const;
+ QDebug debug(CategoryFunction catFunc) const;
QDebug warning() const;
+ QDebug warning(const QLoggingCategory &cat) const;
+ QDebug warning(CategoryFunction catFunc) const;
QDebug critical() const;
+ QDebug critical(const QLoggingCategory &cat) const;
+ QDebug critical(CategoryFunction catFunc) const;
QNoDebug noDebug() const Q_DECL_NOTHROW;
#endif // QT_NO_DEBUG_STREAM
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 8a46f3a6ab..d7ae97e911 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -44,6 +44,10 @@
#include <QtCore/qglobal.h>
+#if defined(__OBJC__) && !defined(__cplusplus)
+# warning "File built in Objective-C mode (.m), but using Qt requires Objective-C++ (.mm)"
+#endif
+
QT_BEGIN_NAMESPACE
@@ -64,7 +68,7 @@ Qt {
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)
+ Q_FLAGS(Alignment Orientations DropActions Edges)
Q_FLAGS(DockWidgetAreas ToolBarAreas)
Q_ENUMS(DockWidgetArea ToolBarArea)
Q_ENUMS(TextFormat)
@@ -512,6 +516,9 @@ public:
AA_SynthesizeTouchForUnhandledMouseEvents = 11,
AA_SynthesizeMouseForUnhandledTouchEvents = 12,
AA_UseHighDpiPixmaps = 13,
+ AA_ForceRasterWidgets = 14,
+ AA_UseDesktopOpenGL = 15,
+ AA_UseOpenGLES = 16,
// Add new attributes before this line
AA_AttributeCount
@@ -998,6 +1005,10 @@ public:
Key_ChannelUp = 0x01000118,
Key_ChannelDown = 0x01000119,
+ Key_Guide = 0x0100011a,
+ Key_Info = 0x0100011b,
+ Key_Settings = 0x0100011c,
+
Key_MediaLast = 0x0100ffff,
// Keypad navigation keys
@@ -1015,6 +1026,7 @@ public:
//Key_Jisho = 0x01020007, // IME: Dictionary key
//Key_Oyayubi_Left = 0x01020008, // IME: Left Oyayubi key
//Key_Oyayubi_Right = 0x01020009, // IME: Right Oyayubi key
+ Key_Exit = 0x0102000a,
// Device keys
Key_Context1 = 0x01100000,
@@ -1235,6 +1247,8 @@ public:
BottomEdge = 0x00008
};
+ Q_DECLARE_FLAGS(Edges, Edge)
+
enum ConnectionType {
AutoConnection,
DirectConnection,
@@ -1318,6 +1332,10 @@ public:
ImHints = 0x100,
ImPreferredLanguage = 0x200,
+ ImAbsolutePosition = 0x400,
+ ImTextBeforeCursor = 0x800,
+ ImTextAfterCursor = 0x1000,
+
ImPlatformData = 0x80000000,
ImQueryInput = ImCursorRectangle | ImCursorPosition | ImSurroundingText |
ImCurrentSelection | ImAnchorPosition,
@@ -1596,6 +1614,19 @@ public:
ScrollUpdate,
ScrollEnd
};
+
+ enum MouseEventSource {
+ MouseEventNotSynthesized,
+ MouseEventSynthesizedBySystem,
+ MouseEventSynthesizedByQt
+ };
+
+ enum MouseEventFlag {
+ MouseEventCreatedDoubleClick = 0x01,
+ MouseEventFlagMask = 0xFF
+ };
+ Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)
+
}
#ifdef Q_MOC_RUN
;
@@ -1606,6 +1637,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::Orientations)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::KeyboardModifiers)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::WindowFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::Alignment)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::Edges)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::ImageConversionFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::DockWidgetAreas)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::ToolBarAreas)
@@ -1618,6 +1650,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodQueries)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodHints)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TouchPointStates)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MouseEventFlags)
#ifndef QT_NO_GESTURES
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::GestureFlags)
#endif
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index ae377e124b..31bc18749b 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -106,17 +106,6 @@
QCoreApplication::setAttribute(), and can be tested for with
QCoreApplication::testAttribute().
- \value AA_ImmediateWidgetCreation Ensures that widgets are created
- as soon as they are constructed. By default, resources for
- widgets are allocated on demand to improve efficiency and
- minimize resource usage. Setting or clearing this attribute
- affects widgets constructed after the change. Setting it
- tells Qt to create toplevel windows immediately.
- Therefore, if it is important to minimize resource
- consumption, do not set this attribute.
-
- \value AA_MSWindowsUseDirect3DByDefault This value is obsolete and
- has no effect.
\value AA_DontShowIconsInMenus Actions with the Icon property won't be
shown in any menus unless specifically set by the
@@ -176,6 +165,32 @@
sizes in layout geometry calculations should typically divide by
QPixmap::devicePixelRatio() to get device-independent layout geometry.
+ \value AA_ForceRasterWidgets Make top-level widgets use pure raster surfaces,
+ and do not support non-native GL-based child widgets.
+
+ \value AA_UseDesktopOpenGL Forces the usage of the desktop OpenGL on
+ platforms that use dynamic loading of the OpenGL implementation.
+ This value has been added in Qt 5.3.
+
+ \value AA_UseOpenGLES Forces the usage of OpenGL ES 2.0 on platforms that
+ use dynamic loading of the OpenGL implementation.
+ This value has been added in Qt 5.3.
+
+ The following values are obsolete:
+
+ \value AA_ImmediateWidgetCreation This attribute is no longer fully
+ supported in Qt 5. It ensures that widgets are created
+ as soon as they are constructed. By default, resources for
+ widgets are allocated on demand to improve efficiency and
+ minimize resource usage. Setting or clearing this attribute
+ affects widgets constructed after the change. Setting it
+ tells Qt to create toplevel windows immediately.
+ Therefore, if it is important to minimize resource
+ consumption, do not set this attribute.
+
+ \value AA_MSWindowsUseDirect3DByDefault This value is obsolete and
+ has no effect.
+
\omitvalue AA_AttributeCount
*/
@@ -699,9 +714,10 @@
retain an alpha channel for some other reason. If the image has no
alpha channel this flag has no effect.
- \omitvalue NoFormatConversion Don't do any format conversions on the image.
+ \value NoFormatConversion Don't do any format conversions on the image.
Can be useful when converting a QImage to a QPixmap for a one-time
- rendering operation for example.
+ rendering operation for example. Note that a QPixmap not in the
+ preferred format will be much slower as a paint device.
*/
/*!
@@ -2430,6 +2446,11 @@
\value ImHints The hints for input method on expected input. (See Qt::InputMethodHints)
\value ImPreferredLanguage The preferred input language.
\value ImPlatformData Platform specific data for input method.
+ \value ImAbsolutePosition The logical position of the cursor within the entire document.
+ \value ImTextBeforeCursor The plain text before the cursor. The widget can decide how much text to return,
+ but \b{must} not return an empty string unless the cursor is at the start of the document.
+ \value ImTextAfterCursor The plain text after the cursor. The widget can decide how much text to return,
+ but \b{must} not return an empty string unless the cursor is at the end of the document.
Masks:
@@ -2895,3 +2916,38 @@
\value ScrollEnd Scrolling has ended, but the scrolling distance
did not change anymore.
*/
+
+/*!
+ \enum Qt::MouseEventSource
+ \since 5.3
+
+ This enum describes the source of a mouse event and can be useful
+ to determine if the event is an artificial mouse event originating
+ from another device such as a touchscreen.
+
+ \value MouseEventNotSynthesized The most common value. On
+ platforms where such information is available this value indicates
+ that the event was generated in response to a genuine mouse event
+ in the system.
+
+ \value MouseEventSynthesizedBySystem Indicates that the mouse
+ event was synthesized from a touch event by the platform.
+
+ \value MouseEventSynthesizedByQt Indicates that the mouse event was
+ synthesized from an unhandled touch event by Qt.
+
+ \sa Qt::AA_SynthesizeMouseForUnhandledTouchEvents
+*/
+
+/*!
+ \enum Qt::MouseEventFlag
+ \since 5.3
+
+ This enum provides additional information concerning a QMouseEvent.
+
+ \value MouseEventCreatedDoubleClick Indicates that Qt has created a
+ MouseButtonDblClick event from this event. The flag is set in the causing
+ MouseButtonPress, and not in the resulting MouseButtonDblCLick.
+
+ \omitvalue MouseEventFlagMask
+*/
diff --git a/src/corelib/global/qnumeric.cpp b/src/corelib/global/qnumeric.cpp
index d09357c26c..7d8bd8c3c6 100644
--- a/src/corelib/global/qnumeric.cpp
+++ b/src/corelib/global/qnumeric.cpp
@@ -41,6 +41,7 @@
#include "qnumeric.h"
#include "qnumeric_p.h"
+#include <string.h>
QT_BEGIN_NAMESPACE
@@ -99,4 +100,139 @@ Q_CORE_EXPORT double qQNaN() { return qt_qnan(); }
Q_CORE_EXPORT double qInf() { return qt_inf(); }
+
+/*!
+ \internal
+ */
+static inline quint32 f2i(float f)
+{
+ quint32 i;
+ memcpy(&i, &f, sizeof(f));
+ return i;
+}
+
+/*!
+ Returns the number of representable floating-point numbers between \a a and \a b.
+
+ This function provides an alternative way of doing approximated comparisons of floating-point
+ numbers similar to qFuzzyCompare(). However, it returns the distance between two numbers, which
+ gives the caller a possibility to choose the accepted error. Errors are relative, so for
+ instance the distance between 1.0E-5 and 1.00001E-5 will give 110, while the distance between
+ 1.0E36 and 1.00001E36 will give 127.
+
+ This function is useful if a floating point comparison requires a certain precision.
+ Therefore, if \a a and \a b are equal it will return 0. The maximum value it will return for 32-bit
+ floating point numbers is 4,278,190,078. This is the distance between \c{-FLT_MAX} and
+ \c{+FLT_MAX}.
+
+ The function does not give meaningful results if any of the arguments are \c Infinite or \c NaN.
+ You can check for this by calling qIsFinite().
+
+ The return value can be considered as the "error", so if you for instance want to compare
+ two 32-bit floating point numbers and all you need is an approximated 24-bit precision, you can
+ use this function like this:
+
+ \code
+ if (qFloatDistance(a, b) < (1 << 7)) { // The last 7 bits are not
+ // significant
+ // precise enough
+ }
+ \endcode
+
+ \sa qFuzzyCompare()
+ \relates <QtGlobal>
+*/
+Q_CORE_EXPORT quint32 qFloatDistance(float a, float b)
+{
+ static const quint32 smallestPositiveFloatAsBits = 0x00000001; // denormalized, (SMALLEST), (1.4E-45)
+ /* Assumes:
+ * IEE754 format.
+ * Integers and floats have the same endian
+ */
+ Q_STATIC_ASSERT(sizeof(quint32) == sizeof(float));
+ Q_ASSERT(qIsFinite(a) && qIsFinite(b));
+ if (a == b)
+ return 0;
+ if ((a < 0) != (b < 0)) {
+ // if they have different signs
+ if (a < 0)
+ a = -a;
+ else /*if (b < 0)*/
+ b = -b;
+ return qFloatDistance(0.0F, a) + qFloatDistance(0.0F, b);
+ }
+ if (a < 0) {
+ a = -a;
+ b = -b;
+ }
+ // at this point a and b should not be negative
+
+ // 0 is special
+ if (!a)
+ return f2i(b) - smallestPositiveFloatAsBits + 1;
+ if (!b)
+ return f2i(a) - smallestPositiveFloatAsBits + 1;
+
+ // finally do the common integer subtraction
+ return a > b ? f2i(a) - f2i(b) : f2i(b) - f2i(a);
+}
+
+
+/*!
+ \internal
+ */
+static inline quint64 d2i(double d)
+{
+ quint64 i;
+ memcpy(&i, &d, sizeof(d));
+ return i;
+}
+
+/*!
+ Returns the number of representable floating-point numbers between \a a and \a b.
+
+ This function serves the same purpose as \c{qFloatDistance(float, float)}, but
+ returns the distance between two \c double numbers. Since the range is larger
+ than for two \c float numbers (\c{[-DBL_MAX,DBL_MAX]}), the return type is quint64.
+
+
+ \sa qFuzzyCompare()
+ \relates <QtGlobal>
+*/
+Q_CORE_EXPORT quint64 qFloatDistance(double a, double b)
+{
+ static const quint64 smallestPositiveFloatAsBits = 0x1; // denormalized, (SMALLEST)
+ /* Assumes:
+ * IEE754 format double precision
+ * Integers and floats have the same endian
+ */
+ Q_STATIC_ASSERT(sizeof(quint64) == sizeof(double));
+ Q_ASSERT(qIsFinite(a) && qIsFinite(b));
+ if (a == b)
+ return 0;
+ if ((a < 0) != (b < 0)) {
+ // if they have different signs
+ if (a < 0)
+ a = -a;
+ else /*if (b < 0)*/
+ b = -b;
+ return qFloatDistance(0.0, a) + qFloatDistance(0.0, b);
+ }
+ if (a < 0) {
+ a = -a;
+ b = -b;
+ }
+ // at this point a and b should not be negative
+
+ // 0 is special
+ if (!a)
+ return d2i(b) - smallestPositiveFloatAsBits + 1;
+ if (!b)
+ return d2i(a) - smallestPositiveFloatAsBits + 1;
+
+ // finally do the common integer subtraction
+ return a > b ? d2i(a) - d2i(b) : d2i(b) - d2i(a);
+}
+
+
QT_END_NAMESPACE
diff --git a/src/corelib/global/qnumeric.h b/src/corelib/global/qnumeric.h
index 25db5443eb..633486dff1 100644
--- a/src/corelib/global/qnumeric.h
+++ b/src/corelib/global/qnumeric.h
@@ -57,6 +57,9 @@ Q_CORE_EXPORT double qSNaN();
Q_CORE_EXPORT double qQNaN();
Q_CORE_EXPORT double qInf();
+Q_CORE_EXPORT quint32 qFloatDistance(float a, float b);
+Q_CORE_EXPORT quint64 qFloatDistance(double a, double b);
+
#define Q_INFINITY (QT_PREPEND_NAMESPACE(qInf)())
#define Q_SNAN (QT_PREPEND_NAMESPACE(qSNaN)())
#define Q_QNAN (QT_PREPEND_NAMESPACE(qQNaN)())
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 623e30aa06..cf7ee1b7aa 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -196,6 +196,7 @@
# define Q_PROCESSOR_X86 6
# define Q_PROCESSOR_X86_64
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
+# define Q_PROCESSOR_WORDSIZE 8
/*
Itanium (IA-64) family, no revisions or variants
@@ -204,6 +205,7 @@
*/
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
# define Q_PROCESSOR_IA64
+# define Q_PROCESSOR_WORDSIZE 8
// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
@@ -324,4 +326,22 @@
# endif
#endif
+/*
+ Define Q_PROCESSOR_WORDSIZE to be the size of the machine's word (usually,
+ the size of the register). On some architectures where a pointer could be
+ smaller than the register, the macro is defined above.
+
+ Falls back to QT_POINTER_SIZE if not set explicitly for the platform.
+*/
+#ifndef Q_PROCESSOR_WORDSIZE
+# ifdef __SIZEOF_POINTER__
+ /* GCC & friends define this */
+# define Q_PROCESSOR_WORDSIZE __SIZEOF_POINTER__
+# elif defined(_LP64) || defined(__LP64__) || defined(WIN64) || defined(_WIN64)
+# define Q_PROCESSOR_WORDSIZE 8
+# else
+# define Q_PROCESSOR_WORDSIZE QT_POINTER_SIZE
+# endif
+#endif
+
#endif // QPROCESSORDETECTION_H
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h
index 5837c8d94e..8478e08416 100644
--- a/src/corelib/global/qtypeinfo.h
+++ b/src/corelib/global/qtypeinfo.h
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <QtCore/qglobal.h>
+#include <QtCore/qtypetraits.h>
#ifndef QTYPEINFO_H
#define QTYPEINFO_H
@@ -60,6 +60,7 @@ class QTypeInfo
public:
enum {
isPointer = false,
+ isIntegral = QtPrivate::is_integral<T>::value,
isComplex = true,
isStatic = true,
isLarge = (sizeof(T)>sizeof(void*)),
@@ -74,6 +75,7 @@ class QTypeInfo<void>
public:
enum {
isPointer = false,
+ isIntegral = false,
isComplex = false,
isStatic = false,
isLarge = false,
@@ -88,6 +90,7 @@ class QTypeInfo<T*>
public:
enum {
isPointer = true,
+ isIntegral = false,
isComplex = false,
isStatic = false,
isLarge = false,
@@ -125,6 +128,7 @@ public:
isStatic = QTypeInfo<T1>::isStatic || QTypeInfo<T2>::isStatic || QTypeInfo<T3>::isStatic || QTypeInfo<T4>::isStatic,
isLarge = sizeof(T) > sizeof(void*),
isPointer = false,
+ isIntegral = false,
isDummy = false,
sizeOf = sizeof(T)
};
@@ -138,6 +142,7 @@ class QTypeInfo< CONTAINER<T> > \
public: \
enum { \
isPointer = false, \
+ isIntegral = false, \
isComplex = true, \
isStatic = false, \
isLarge = (sizeof(CONTAINER<T>) > sizeof(void*)), \
@@ -180,6 +185,7 @@ public: \
isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \
isLarge = (sizeof(TYPE)>sizeof(void*)), \
isPointer = false, \
+ isIntegral = QtPrivate::is_integral< TYPE >::value, \
isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0), \
sizeOf = sizeof(TYPE) \
}; \
@@ -239,5 +245,14 @@ Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
#endif
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+// We can't do it now because it would break BC on QList<char32_t>
+Q_DECLARE_TYPEINFO(char16_t, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(char32_t, Q_PRIMITIVE_TYPE);
+# if !defined(Q_CC_MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
+Q_DECLARE_TYPEINFO(wchar_t, Q_PRIMITIVE_TYPE);
+# endif
+#endif // Qt 6
+
QT_END_NAMESPACE
#endif // QTYPEINFO_H