summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/configure.json18
-rw-r--r--src/corelib/doc/src/json.qdoc2
-rw-r--r--src/corelib/global/global.pri1
-rw-r--r--src/corelib/global/qcompilerdetection.h67
-rw-r--r--src/corelib/global/qglobal.cpp25
-rw-r--r--src/corelib/global/qglobalstatic.qdoc (renamed from src/corelib/global/qglobalstatic.cpp)2
-rw-r--r--src/corelib/global/qlogging.cpp2
-rw-r--r--src/corelib/global/qoperatingsystemversion.cpp8
-rw-r--r--src/corelib/global/qoperatingsystemversion.h1
-rw-r--r--src/corelib/io/qloggingcategory.cpp26
-rw-r--r--src/corelib/io/qprocess.cpp36
-rw-r--r--src/corelib/io/qprocess_darwin.mm2
-rw-r--r--src/corelib/io/qprocess_p.h39
-rw-r--r--src/corelib/io/qprocess_unix.cpp14
-rw-r--r--src/corelib/io/qprocess_win.cpp14
-rw-r--r--src/corelib/json/qjson_p.h2
-rw-r--r--src/corelib/kernel/kernel.pri2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp15
-rw-r--r--src/corelib/kernel/qjnihelpers_p.h8
-rw-r--r--src/corelib/tools/qbytearray.h2
-rw-r--r--src/corelib/tools/qcollator.cpp2
-rw-r--r--src/corelib/tools/qcollator_macx.cpp2
-rw-r--r--src/corelib/tools/qsimd.cpp8
-rw-r--r--src/corelib/tools/qsimd_p.h6
-rw-r--r--src/corelib/tools/qstring.h2
-rw-r--r--src/corelib/tools/qtimezone.cpp8
26 files changed, 176 insertions, 138 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 0e9830c5e2..7fca3137eb 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -84,6 +84,14 @@
"-ldl"
]
},
+ "librt": {
+ "label": "clock_gettime()",
+ "test": "unix/clock-gettime",
+ "sources": [
+ "",
+ "-lrt"
+ ]
+ },
"pcre2": {
"label": "PCRE2",
"test": "unix/pcre2",
@@ -119,15 +127,11 @@
"type": "compile",
"test": "common/atomicfptr"
},
- "clock-gettime": {
- "label": "clock_gettime()",
- "type": "compile",
- "test": "unix/clock-gettime"
- },
"clock-monotonic": {
"label": "POSIX monotonic clock",
"type": "compile",
- "test": "unix/clock-monotonic"
+ "test": "unix/clock-monotonic",
+ "use": "librt"
},
"cloexec": {
"label": "O_CLOEXEC",
@@ -214,7 +218,7 @@
"features": {
"clock-gettime": {
"label": "clock_gettime()",
- "condition": "tests.clock-gettime",
+ "condition": "config.unix && libs.librt",
"output": [ "privateFeature" ]
},
"clock-monotonic": {
diff --git a/src/corelib/doc/src/json.qdoc b/src/corelib/doc/src/json.qdoc
index a32772f910..4c7e62a10a 100644
--- a/src/corelib/doc/src/json.qdoc
+++ b/src/corelib/doc/src/json.qdoc
@@ -45,7 +45,7 @@
access.
More details about the JSON data format can be found at \l{http://json.org}{json.org}
- and in \l{http://tools.ietf.org/html/rfc4627}{RFC-4627}.
+ and in \l{https://tools.ietf.org/html/rfc7159}{RFC-7159}.
\tableofcontents
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index b95cdaa014..a087452d06 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -29,7 +29,6 @@ HEADERS += \
SOURCES += \
global/archdetect.cpp \
global/qglobal.cpp \
- global/qglobalstatic.cpp \
global/qlibraryinfo.cpp \
global/qmalloc.cpp \
global/qnumeric.cpp \
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index c221115e8f..9ffd164b61 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1061,6 +1061,37 @@
#endif
/*
+ * SG10's SD-6 feature detection and some useful extensions from Clang and GCC
+ * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
+ * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
+ */
+#ifdef __has_builtin
+# define QT_HAS_BUILTIN(x) __has_builtin(x)
+#else
+# define QT_HAS_BUILTIN(x) 0
+#endif
+#ifdef __has_attribute
+# define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
+#else
+# define QT_HAS_ATTRIBUTE(x) 0
+#endif
+#ifdef __has_cpp_attribute
+# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
+#else
+# define QT_HAS_CPP_ATTRIBUTE(x) 0
+#endif
+#ifdef __has_include
+# define QT_HAS_INCLUDE(x) __has_include(x)
+#else
+# define QT_HAS_INCLUDE(x) 0
+#endif
+#ifdef __has_include_next
+# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
+#else
+# define QT_HAS_INCLUDE_NEXT(x) 0
+#endif
+
+/*
* C++11 keywords and expressions
*/
#ifdef Q_COMPILER_NULLPTR
@@ -1141,6 +1172,11 @@
# define Q_DECL_ALIGN(n) alignas(n)
#endif
+#if QT_HAS_CPP_ATTRIBUTE(nodiscard) // P0188R1
+# undef Q_REQUIRED_RESULT
+# define Q_REQUIRED_RESULT [[nodiscard]]
+#endif
+
/*
* Fallback macros to certain compiler features
*/
@@ -1215,37 +1251,6 @@
#ifndef QT_MAKE_CHECKED_ARRAY_ITERATOR
# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x)
#endif
-
-/*
- * SG10's SD-6 feature detection and some useful extensions from Clang and GCC
- * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
- * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
- */
-#ifdef __has_builtin
-# define QT_HAS_BUILTIN(x) __has_builtin(x)
-#else
-# define QT_HAS_BUILTIN(x) 0
-#endif
-#ifdef __has_attribute
-# define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
-#else
-# define QT_HAS_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_cpp_attribute
-# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
-#else
-# define QT_HAS_CPP_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_include
-# define QT_HAS_INCLUDE(x) __has_include(x)
-#else
-# define QT_HAS_INCLUDE(x) 0
-#endif
-#ifdef __has_include_next
-# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
-#else
-# define QT_HAS_INCLUDE_NEXT(x) 0
-#endif
#ifdef __has_feature
# define QT_HAS_FEATURE(x) __has_feature(x)
#else
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 4c1b210489..9c05b9650c 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -85,12 +85,6 @@
# include <sys/systeminfo.h>
#endif
-#if defined(Q_OS_DARWIN)
-# include <mach/machine.h>
-# include <sys/sysctl.h>
-# include <sys/types.h>
-#endif
-
#ifdef Q_OS_UNIX
#include <sys/utsname.h>
#include <private/qcore_unix_p.h>
@@ -2057,6 +2051,8 @@ static const char *osVer_helper(QOperatingSystemVersion version = QOperatingSyst
return "El Capitan";
case 12:
return "Sierra";
+ case 13:
+ return "High Sierra";
}
}
// unknown, future version
@@ -2489,20 +2485,9 @@ QString QSysInfo::currentCpuArchitecture()
case PROCESSOR_ARCHITECTURE_IA64:
return QStringLiteral("ia64");
}
-#elif defined(Q_OS_DARWIN)
- cpu_type_t type;
- size_t size = sizeof(type);
- sysctlbyname("hw.cputype", &type, &size, NULL, 0);
- switch (type) {
- case CPU_TYPE_X86:
- return QStringLiteral("i386");
- case CPU_TYPE_X86_64:
- return QStringLiteral("x86_64");
- case CPU_TYPE_ARM:
- return QStringLiteral("arm");
- case CPU_TYPE_ARM64:
- return QStringLiteral("arm64");
- }
+#elif defined(Q_OS_DARWIN) && !defined(Q_OS_MACOS)
+ // iOS-based OSes do not return the architecture on uname(2)'s result.
+ return buildCpuArchitecture();
#elif defined(Q_OS_UNIX)
long ret = -1;
struct utsname u;
diff --git a/src/corelib/global/qglobalstatic.cpp b/src/corelib/global/qglobalstatic.qdoc
index d1c522a79a..8c34739d38 100644
--- a/src/corelib/global/qglobalstatic.cpp
+++ b/src/corelib/global/qglobalstatic.qdoc
@@ -37,8 +37,6 @@
**
****************************************************************************/
-#include "qglobalstatic.h"
-
/*!
\macro Q_GLOBAL_STATIC(Type, VariableName)
\since 5.1
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index a52f0de9f0..6602d53b08 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -274,7 +274,7 @@ Q_CORE_EXPORT bool qt_logging_to_console()
\sa QMessageLogContext, qDebug(), qInfo(), qWarning(), qCritical(), qFatal()
*/
-#ifdef Q_OS_WIN
+#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) Q_DECL_NOEXCEPT
{
size_t len = qstrlen(s);
diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp
index bed08f0000..244f294312 100644
--- a/src/corelib/global/qoperatingsystemversion.cpp
+++ b/src/corelib/global/qoperatingsystemversion.cpp
@@ -413,6 +413,14 @@ const QOperatingSystemVersion QOperatingSystemVersion::MacOSSierra =
QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 12);
/*!
+ \variable QOperatingSystemVersion::MacOSHighSierra
+ \brief a version corresponding to macOS High Sierra (version 10.13).
+ \since 5.9.1
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::MacOSHighSierra =
+ QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 13);
+
+/*!
\variable QOperatingSystemVersion::AndroidJellyBean
\brief a version corresponding to Android Jelly Bean (version 4.1, API level 16).
\since 5.9
diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h
index cc14d701e1..295365aad1 100644
--- a/src/corelib/global/qoperatingsystemversion.h
+++ b/src/corelib/global/qoperatingsystemversion.h
@@ -69,6 +69,7 @@ public:
static const QOperatingSystemVersion OSXYosemite;
static const QOperatingSystemVersion OSXElCapitan;
static const QOperatingSystemVersion MacOSSierra;
+ static const QOperatingSystemVersion MacOSHighSierra;
static const QOperatingSystemVersion AndroidJellyBean;
static const QOperatingSystemVersion AndroidJellyBean_MR1;
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index 967a614a2d..69af936bca 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -63,6 +63,7 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\class QLoggingCategory
\inmodule QtCore
\since 5.2
+ \threadsafe
\brief The QLoggingCategory class represents a category, or 'area' in the
logging infrastructure.
@@ -95,6 +96,9 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\li Category names starting with \c{qt} are reserved for Qt modules.
\endlist
+ QLoggingCategory objects implicitly defined by Q_LOGGING_CATEGORY()
+ are created on first use in a thread-safe manner.
+
\section1 Checking Category Configuration
QLoggingCategory provides \l isDebugEnabled(), \l isInfoEnabled(),
@@ -458,6 +462,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments are not processed if debug output for the category is not
enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qDebug()
*/
@@ -477,6 +483,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments might not be processed if debug output for the category is
not enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qDebug()
*/
@@ -499,6 +507,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments are not processed if debug output for the category is not
enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qInfo()
*/
@@ -518,6 +528,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments might not be processed if debug output for the category is
not enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qInfo()
*/
@@ -540,6 +552,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments are not processed if warning output for the category is not
enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qWarning()
*/
@@ -559,6 +573,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments might not be processed if warning output for the category is
not enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qWarning()
*/
@@ -581,6 +597,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments are not processed if critical output for the category is not
enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qCritical()
*/
@@ -600,6 +618,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\note Arguments might not be processed if critical output for the category
is not enabled, so do not rely on any side effects.
+ \note Using the macro is thread-safe.
+
\sa qCritical()
*/
/*!
@@ -624,7 +644,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\a string identifier. By default, all message types are enabled.
Only one translation unit in a library or executable can define a category
- with a specific name.
+ with a specific name. The implicitly defined QLoggingCategory object is
+ created on first use, in a thread-safe manner.
This macro must be used outside of a class or method.
*/
@@ -640,7 +661,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
and more severe are enabled, types with a lower severity are disabled.
Only one translation unit in a library or executable can define a category
- with a specific name.
+ with a specific name. The implicitly defined QLoggingCategory object is
+ created on first use, in a thread-safe manner.
This macro must be used outside of a class or method. It is only defined
if variadic macros are supported.
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index a3343423db..9da0fe59b5 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -154,8 +154,8 @@ QT_BEGIN_NAMESPACE
QStringList QProcessEnvironmentPrivate::toList() const
{
QStringList result;
- result.reserve(hash.size());
- for (Hash::const_iterator it = hash.cbegin(), end = hash.cend(); it != end; ++it)
+ result.reserve(vars.size());
+ for (auto it = vars.cbegin(), end = vars.cend(); it != end; ++it)
result << nameToString(it.key()) + QLatin1Char('=') + valueToString(it.value());
return result;
}
@@ -181,9 +181,9 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list
QStringList QProcessEnvironmentPrivate::keys() const
{
QStringList result;
- result.reserve(hash.size());
- Hash::ConstIterator it = hash.constBegin(),
- end = hash.constEnd();
+ result.reserve(vars.size());
+ auto it = vars.constBegin();
+ const auto end = vars.constEnd();
for ( ; it != end; ++it)
result << nameToString(it.key());
return result;
@@ -191,14 +191,14 @@ QStringList QProcessEnvironmentPrivate::keys() const
void QProcessEnvironmentPrivate::insert(const QProcessEnvironmentPrivate &other)
{
- Hash::ConstIterator it = other.hash.constBegin(),
- end = other.hash.constEnd();
+ auto it = other.vars.constBegin();
+ const auto end = other.vars.constEnd();
for ( ; it != end; ++it)
- hash.insert(it.key(), it.value());
+ vars.insert(it.key(), it.value());
#ifdef Q_OS_UNIX
- QHash<QString, Key>::ConstIterator nit = other.nameMap.constBegin(),
- nend = other.nameMap.constEnd();
+ auto nit = other.nameMap.constBegin();
+ const auto nend = other.nameMap.constEnd();
for ( ; nit != nend; ++nit)
nameMap.insert(nit.key(), nit.value());
#endif
@@ -271,7 +271,7 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
if (d) {
if (other.d) {
QProcessEnvironmentPrivate::OrderedMutexLocker locker(d, other.d);
- return d->hash == other.d->hash;
+ return d->vars == other.d->vars;
} else {
return isEmpty();
}
@@ -289,7 +289,7 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
bool QProcessEnvironment::isEmpty() const
{
// Needs no locking, as no hash nodes are accessed
- return d ? d->hash.isEmpty() : true;
+ return d ? d->vars.isEmpty() : true;
}
/*!
@@ -301,7 +301,7 @@ bool QProcessEnvironment::isEmpty() const
void QProcessEnvironment::clear()
{
if (d)
- d->hash.clear();
+ d->vars.clear();
// Unix: Don't clear d->nameMap, as the environment is likely to be
// re-populated with the same keys again.
}
@@ -318,7 +318,7 @@ bool QProcessEnvironment::contains(const QString &name) const
if (!d)
return false;
QProcessEnvironmentPrivate::MutexLocker locker(d);
- return d->hash.contains(d->prepareName(name));
+ return d->vars.contains(d->prepareName(name));
}
/*!
@@ -337,7 +337,7 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
{
// our re-impl of detach() detaches from null
d.detach(); // detach before prepareName()
- d->hash.insert(d->prepareName(name), d->prepareValue(value));
+ d->vars.insert(d->prepareName(name), d->prepareValue(value));
}
/*!
@@ -352,7 +352,7 @@ void QProcessEnvironment::remove(const QString &name)
{
if (d) {
d.detach(); // detach before prepareName()
- d->hash.remove(d->prepareName(name));
+ d->vars.remove(d->prepareName(name));
}
}
@@ -369,8 +369,8 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
return defaultValue;
QProcessEnvironmentPrivate::MutexLocker locker(d);
- QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name));
- if (it == d->hash.constEnd())
+ const auto it = d->vars.constFind(d->prepareName(name));
+ if (it == d->vars.constEnd())
return defaultValue;
return d->valueToString(it.value());
diff --git a/src/corelib/io/qprocess_darwin.mm b/src/corelib/io/qprocess_darwin.mm
index dd7a8275b9..2c3c296cb4 100644
--- a/src/corelib/io/qprocess_darwin.mm
+++ b/src/corelib/io/qprocess_darwin.mm
@@ -48,7 +48,7 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
__block QProcessEnvironment env;
[[[NSProcessInfo processInfo] environment]
enumerateKeysAndObjectsUsingBlock:^(NSString *name, NSString *value, BOOL *__unused stop) {
- env.d->hash.insert(
+ env.d->vars.insert(
QProcessEnvironmentPrivate::Key(QString::fromNSString(name).toLocal8Bit()),
QProcessEnvironmentPrivate::Value(QString::fromNSString(value).toLocal8Bit()));
}];
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index bea54f86da..deb29dca0a 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -55,6 +55,7 @@
#include "QtCore/qprocess.h"
#include "QtCore/qstringlist.h"
#include "QtCore/qhash.h"
+#include "QtCore/qmap.h"
#include "QtCore/qshareddata.h"
#include "private/qiodevice_p.h"
@@ -90,22 +91,19 @@ public:
QProcEnvKey(const QProcEnvKey &other) : QString(other) {}
bool operator==(const QProcEnvKey &other) const { return !compare(other, Qt::CaseInsensitive); }
};
-inline uint qHash(const QProcEnvKey &key) { return qHash(key.toCaseFolded()); }
-typedef QString QProcEnvValue;
-#else
-class QProcEnvKey
+inline bool operator<(const QProcEnvKey &a, const QProcEnvKey &b)
{
-public:
- QProcEnvKey() : hash(0) {}
- explicit QProcEnvKey(const QByteArray &other) : key(other), hash(qHash(key)) {}
- QProcEnvKey(const QProcEnvKey &other) { *this = other; }
- bool operator==(const QProcEnvKey &other) const { return key == other.key; }
+ // On windows use case-insensitive ordering because that is how Windows needs the environment
+ // block sorted (https://msdn.microsoft.com/en-us/library/windows/desktop/ms682009(v=vs.85).aspx)
+ return a.compare(b, Qt::CaseInsensitive) < 0;
+}
- QByteArray key;
- uint hash;
-};
-inline uint qHash(const QProcEnvKey &key) Q_DECL_NOTHROW { return key.hash; }
+Q_DECLARE_TYPEINFO(QProcEnvKey, Q_MOVABLE_TYPE);
+
+typedef QString QProcEnvValue;
+#else
+using QProcEnvKey = QByteArray;
class QProcEnvValue
{
@@ -138,7 +136,6 @@ public:
};
Q_DECLARE_TYPEINFO(QProcEnvValue, Q_MOVABLE_TYPE);
#endif
-Q_DECLARE_TYPEINFO(QProcEnvKey, Q_MOVABLE_TYPE);
class QProcessEnvironmentPrivate: public QSharedData
{
@@ -161,13 +158,13 @@ public:
inline Key prepareName(const QString &name) const
{
Key &ent = nameMap[name];
- if (ent.key.isEmpty())
- ent = Key(name.toLocal8Bit());
+ if (ent.isEmpty())
+ ent = name.toLocal8Bit();
return ent;
}
inline QString nameToString(const Key &name) const
{
- const QString sname = QString::fromLocal8Bit(name.key);
+ const QString sname = QString::fromLocal8Bit(name);
nameMap[sname] = name;
return sname;
}
@@ -197,17 +194,17 @@ public:
// do not need a lock, as they detach objects (however, we need to
// ensure that they really detach before using prepareName()).
MutexLocker locker(&other);
- hash = other.hash;
+ vars = other.vars;
nameMap = other.nameMap;
// We need to detach our members, so that our mutex can protect them.
// As we are being detached, they likely would be detached a moment later anyway.
- hash.detach();
+ vars.detach();
nameMap.detach();
}
#endif
- typedef QHash<Key, Value> Hash;
- Hash hash;
+ using Map = QMap<Key, Value>;
+ Map vars;
#ifdef Q_OS_UNIX
typedef QHash<QString, Key> NameHash;
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 2b47f3e5b1..35bb44fed4 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -137,7 +137,7 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
QByteArray name(entry, equal - entry);
QByteArray value(equal + 1);
- env.d->hash.insert(QProcessEnvironmentPrivate::Key(name),
+ env.d->vars.insert(QProcessEnvironmentPrivate::Key(name),
QProcessEnvironmentPrivate::Value(value));
}
return env;
@@ -339,7 +339,7 @@ bool QProcessPrivate::openChannel(Channel &channel)
}
}
-static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Hash &environment, int *envc)
+static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Map &environment, int *envc)
{
*envc = 0;
if (environment.isEmpty())
@@ -349,10 +349,10 @@ static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Hash &environm
envp[environment.count()] = 0;
envp[environment.count() + 1] = 0;
- QProcessEnvironmentPrivate::Hash::ConstIterator it = environment.constBegin();
- const QProcessEnvironmentPrivate::Hash::ConstIterator end = environment.constEnd();
+ auto it = environment.constBegin();
+ const auto end = environment.constEnd();
for ( ; it != end; ++it) {
- QByteArray key = it.key().key;
+ QByteArray key = it.key();
QByteArray value = it.value().bytes();
key.reserve(key.length() + 1 + value.length());
key.append('=');
@@ -445,7 +445,7 @@ void QProcessPrivate::startProcess()
char **envp = 0;
if (environment.d.constData()) {
QProcessEnvironmentPrivate::MutexLocker locker(environment.d);
- envp = _q_dupEnvironment(environment.d.constData()->hash, &envc);
+ envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
}
// Encode the working directory if it's non-empty, otherwise just pass 0.
@@ -969,7 +969,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
char **envp = nullptr;
if (environment.d.constData()) {
QProcessEnvironmentPrivate::MutexLocker locker(environment.d);
- envp = _q_dupEnvironment(environment.d.constData()->hash, &envc);
+ envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
}
QByteArray tmp;
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 0f6a61496d..2bbc4eddd0 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -75,7 +75,7 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
int nameLen = equal - entry;
QString name = QString::fromWCharArray(entry, nameLen);
QString value = QString::fromWCharArray(equal + 1, entryLen - nameLen - 1);
- env.d->hash.insert(QProcessEnvironmentPrivate::Key(name), value);
+ env.d->vars.insert(QProcessEnvironmentPrivate::Key(name), value);
}
entry += entryLen + 1;
}
@@ -398,11 +398,11 @@ static QString qt_create_commandline(const QString &program, const QStringList &
return args;
}
-static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Hash &environment)
+static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Map &environment)
{
QByteArray envlist;
if (!environment.isEmpty()) {
- QProcessEnvironmentPrivate::Hash copy = environment;
+ QProcessEnvironmentPrivate::Map copy = environment;
// add PATH if necessary (for DLL loading)
QProcessEnvironmentPrivate::Key pathKey(QLatin1String("PATH"));
@@ -421,8 +421,8 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Hash &
}
int pos = 0;
- QProcessEnvironmentPrivate::Hash::ConstIterator it = copy.constBegin(),
- end = copy.constEnd();
+ auto it = copy.constBegin();
+ const auto end = copy.constEnd();
static const wchar_t equal = L'=';
static const wchar_t nul = L'\0';
@@ -507,7 +507,7 @@ void QProcessPrivate::startProcess()
const QString args = qt_create_commandline(program, arguments, nativeArguments);
QByteArray envlist;
if (environment.d.constData())
- envlist = qt_create_environment(environment.d.constData()->hash);
+ envlist = qt_create_environment(environment.d.constData()->vars);
#if defined QPROCESS_DEBUG
qDebug("Creating process");
@@ -891,7 +891,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
void *envPtr = nullptr;
QByteArray envlist;
if (environment.d.constData()) {
- envlist = qt_create_environment(environment.d.constData()->hash);
+ envlist = qt_create_environment(environment.d.constData()->vars);
envPtr = envlist.data();
}
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 0c78fadfc7..c012ec2662 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -243,7 +243,7 @@ public:
uint i = qFromLittleEndian(val);
i <<= 32 - width - pos;
int t = (int) i;
- t >>= pos;
+ t >>= 32 - width;
return t;
}
bool operator !() const {
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 0e6ff17b8f..29bd5bbc6c 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -162,7 +162,7 @@ unix|integrity {
QMAKE_USE_PRIVATE += glib
}
- qtConfig(clock-gettime): include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
+ qtConfig(clock-gettime): QMAKE_USE_PRIVATE += librt
!android {
SOURCES += kernel/qsharedmemory_posix.cpp \
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 306c0845ef..dc60b0bc2b 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -80,13 +80,13 @@ class PermissionsResultClass : public QObject
Q_OBJECT
public:
PermissionsResultClass(const QtAndroidPrivate::PermissionsResultFunc &func) : m_func(func) {}
- Q_INVOKABLE void sendResult(const QtAndroidPrivate::PermissionsHash &result) { m_func(result); }
+ Q_INVOKABLE void sendResult(const QtAndroidPrivate::PermissionsHash &result) { m_func(result); delete this;}
private:
QtAndroidPrivate::PermissionsResultFunc m_func;
};
-typedef QHash<int, QSharedPointer<PermissionsResultClass>> PendingPermissionRequestsHash;
+typedef QHash<int, PermissionsResultClass*> PendingPermissionRequestsHash;
Q_GLOBAL_STATIC(PendingPermissionRequestsHash, g_pendingPermissionRequests);
static QBasicMutex g_pendingPermissionRequestsMutex;
static int nextRequestCode()
@@ -131,11 +131,11 @@ static void sendRequestPermissionsResult(JNIEnv *env, jobject /*obj*/, jint requ
// show an error or something ?
return;
}
- auto request = std::move(*it);
+ auto request = *it;
g_pendingPermissionRequests->erase(it);
locker.unlock();
- Qt::ConnectionType connection = QThread::currentThread() == request->thread() ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
+ Qt::ConnectionType connection = QThread::currentThread() == request->thread() ? Qt::DirectConnection : Qt::QueuedConnection;
QtAndroidPrivate::PermissionsHash hash;
const int size = env->GetArrayLength(permissions);
std::unique_ptr<jint[]> results(new jint[size]);
@@ -147,7 +147,7 @@ static void sendRequestPermissionsResult(JNIEnv *env, jobject /*obj*/, jint requ
QtAndroidPrivate::PermissionsResult::Denied;
hash[permission] = value;
}
- QMetaObject::invokeMethod(request.data(), "sendResult", connection, Q_ARG(QtAndroidPrivate::PermissionsHash, hash));
+ QMetaObject::invokeMethod(request, "sendResult", connection, Q_ARG(QtAndroidPrivate::PermissionsHash, hash));
}
static jboolean dispatchGenericMotionEvent(JNIEnv *, jclass, jobject event)
@@ -410,6 +410,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
env->DeleteLocalRef(jQtNative);
+ qRegisterMetaType<QtAndroidPrivate::PermissionsHash>();
return JNI_OK;
}
@@ -491,13 +492,13 @@ void QtAndroidPrivate::requestPermissions(JNIEnv *env, const QStringList &permis
const int requestCode = nextRequestCode();
if (!directCall) {
QMutexLocker locker(&g_pendingPermissionRequestsMutex);
- (*g_pendingPermissionRequests)[requestCode] = QSharedPointer<PermissionsResultClass>::create(callbackFunc);
+ (*g_pendingPermissionRequests)[requestCode] = new PermissionsResultClass(callbackFunc);
}
runOnAndroidThread([permissions, callbackFunc, requestCode, directCall] {
if (directCall) {
QMutexLocker locker(&g_pendingPermissionRequestsMutex);
- (*g_pendingPermissionRequests)[requestCode] = QSharedPointer<PermissionsResultClass>::create(callbackFunc);
+ (*g_pendingPermissionRequests)[requestCode] = new PermissionsResultClass(callbackFunc);
}
QJNIEnvironmentPrivate env;
diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h
index 9fa47d5302..7562d2c6f1 100644
--- a/src/corelib/kernel/qjnihelpers_p.h
+++ b/src/corelib/kernel/qjnihelpers_p.h
@@ -52,8 +52,10 @@
//
#include <jni.h>
-#include <QtCore/private/qglobal_p.h>
#include <functional>
+#include <QtCore/private/qglobal_p.h>
+#include <QHash>
+#include <QMetaType>
QT_BEGIN_NAMESPACE
@@ -117,7 +119,7 @@ namespace QtAndroidPrivate
Q_CORE_EXPORT void runOnAndroidThreadSync(const Runnable &runnable, JNIEnv *env, int timeoutMs = INT_MAX);
Q_CORE_EXPORT void runOnUiThread(QRunnable *runnable, JNIEnv *env);
Q_CORE_EXPORT void requestPermissions(JNIEnv *env, const QStringList &permissions, const PermissionsResultFunc &callbackFunc, bool directCall = false);
- Q_CORE_EXPORT QHash<QString, PermissionsResult> requestPermissionsSync(JNIEnv *env, const QStringList &permissions, int timeoutMs = INT_MAX);
+ Q_CORE_EXPORT PermissionsHash requestPermissionsSync(JNIEnv *env, const QStringList &permissions, int timeoutMs = INT_MAX);
Q_CORE_EXPORT PermissionsResult checkPermission(const QString &permission);
Q_CORE_EXPORT bool shouldShowRequestPermissionRationale(const QString &permission);
@@ -145,4 +147,6 @@ namespace QtAndroidPrivate
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QtAndroidPrivate::PermissionsHash)
+
#endif // QJNIHELPERS_H
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 144216a6ef..32f4817ce6 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -249,7 +249,7 @@ public:
void chop(int n);
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
-# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
+# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_CPP_ATTRIBUTE(nodiscard)
// required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941
# pragma push_macro("Q_REQUIRED_RESULT")
# undef Q_REQUIRED_RESULT
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp
index e34d16079f..f1e3d6652d 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/tools/qcollator.cpp
@@ -254,7 +254,7 @@ bool QCollator::numericMode() const
The default is locale dependent.
- \note This method is not currently supported on Apple platforms or if Qt is configured to not use ICU on Linux.
+ \note This method is not currently supported if Qt is configured to not use ICU on Linux.
\sa ignorePunctuation()
*/
diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp
index d468272430..9aa59a81dc 100644
--- a/src/corelib/tools/qcollator_macx.cpp
+++ b/src/corelib/tools/qcollator_macx.cpp
@@ -66,7 +66,7 @@ void QCollatorPrivate::init()
options |= kUCCollateCaseInsensitiveMask;
if (numericMode)
options |= kUCCollateDigitsAsNumberMask | kUCCollateDigitsOverrideMask;
- if (ignorePunctuation)
+ if (!ignorePunctuation)
options |= kUCCollatePunctuationSignificantMask;
OSStatus status = UCCreateCollator(
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index d4edf459de..4c6f08c774 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -721,6 +721,14 @@ void qDumpCPUFeatures()
printf("%s%s", features_string + features_indices[i],
minFeature & (Q_UINT64_C(1) << i) ? "[required]" : "");
}
+ if ((features = (qCompilerCpuFeatures & ~features))) {
+ printf("\n!!!!!!!!!!!!!!!!!!!!\n!!! Missing required features:");
+ for (int i = 0; i < features_count; ++i) {
+ if (features & (Q_UINT64_C(1) << i))
+ printf("%s", features_string + features_indices[i]);
+ }
+ printf("\n!!! Applications will likely crash with \"Invalid Instruction\"\n!!!!!!!!!!!!!!!!!!!!");
+ }
puts("");
}
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 44f6f1cc91..3ef29f4823 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -232,7 +232,7 @@
#if defined(__SSE4_2__) || (defined(QT_COMPILER_SUPPORTS_SSE4_2) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS))
#include <nmmintrin.h>
-# if defined(__SSE4_2__) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)
+# if defined(__SSE4_2__) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS) && (defined(Q_CC_INTEL) || defined(Q_CC_MSVC))
// POPCNT instructions:
// All processors that support SSE4.2 support POPCNT
// (but neither MSVC nor the Intel compiler define this macro)
@@ -245,7 +245,7 @@
// immintrin.h is the ultimate header, we don't need anything else after this
#include <immintrin.h>
-# if defined(__AVX__) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)
+# if defined(__AVX__) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS) && (defined(Q_CC_INTEL) || defined(Q_CC_MSVC))
// AES, PCLMULQDQ instructions:
// All processors that support AVX support AES, PCLMULQDQ
// (but neither MSVC nor the Intel compiler define these macros)
@@ -253,7 +253,7 @@
# define __PCLMUL__ 1
# endif
-# if defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)
+# if defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS) && (defined(Q_CC_INTEL) || defined(Q_CC_MSVC))
// F16C & RDRAND instructions:
// All processors that support AVX2 support F16C & RDRAND:
// (but neither MSVC nor the Intel compiler define these macros)
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index d5301a396f..9d87cd1077 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -407,7 +407,7 @@ public:
Q_REQUIRED_RESULT QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
-# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
+# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_CPP_ATTRIBUTE(nodiscard)
// required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941
# pragma push_macro("Q_REQUIRED_RESULT")
# undef Q_REQUIRED_RESULT
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index 0b331be503..6a26993549 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -958,7 +958,13 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
int country;
QString comment;
ds >> ianaId >> utcOffset >> name >> abbreviation >> country >> comment;
- tz = QTimeZone(ianaId.toUtf8(), utcOffset, name, abbreviation, (QLocale::Country) country, comment);
+ // Try creating as a system timezone, which succeeds (producing a valid
+ // zone) iff ianaId is valid; we can then ignore the other data.
+ tz = QTimeZone(ianaId.toUtf8());
+ // If not, then construct a custom timezone using all the saved values:
+ if (!tz.isValid())
+ tz = QTimeZone(ianaId.toUtf8(), utcOffset, name, abbreviation,
+ QLocale::Country(country), comment);
} else {
tz = QTimeZone(ianaId.toUtf8());
}