summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-04-11 23:01:43 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-11 23:01:43 +0200
commit4c1e15548a288455a5a62dcefacd7c9a44736346 (patch)
tree0273cad922b92b008870808fb67403131383313e /src/corelib
parentc501eb8bece9c9de37f7f0839a8396fbfa697fec (diff)
parent98d3e40fb7c88b670a93e73dace2d0f05a5f903c (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp10
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp12
-rw-r--r--src/corelib/global/qcompilerdetection.h10
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qlibraryinfo.cpp4
-rw-r--r--src/corelib/global/qlogging.cpp16
-rw-r--r--src/corelib/global/qprocessordetection.h12
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp7
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm2
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp3
-rw-r--r--src/corelib/io/qloggingregistry.cpp13
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp4
-rw-r--r--src/corelib/kernel/qjni.cpp11
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp8
-rw-r--r--src/corelib/thread/qmutex.cpp12
-rw-r--r--src/corelib/thread/qmutex.h6
-rw-r--r--src/corelib/tools/qbytearray.h2
-rw-r--r--src/corelib/tools/qstring.cpp18
19 files changed, 101 insertions, 55 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 139876de3a..f7bb1e91bd 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -277,10 +277,12 @@ void QUnifiedTimer::updateAnimationTimers(qint64 currentTick)
lastTick = totalElapsed;
- //we make sure we only call update time if the time has actually changed
- //it might happen in some cases that the time doesn't change because events are delayed
- //when the CPU load is high
- if (delta) {
+ //we make sure we only call update time if the time has actually advanced
+ //* it might happen in some cases that the time doesn't change because events are delayed
+ // when the CPU load is high
+ //* it might happen in some cases that the delta is negative because the animation driver
+ // advances faster than time.elapsed()
+ if (delta > 0) {
insideTick = true;
if (profilerCallback)
profilerCallback(delta);
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp
index e8ec95f4ee..4b2916a619 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp
@@ -115,7 +115,7 @@ a[2] = a[0] ^ a[1];
QBitArray a(3);
QBitArray b(2);
a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
-b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+b[0] = 1; b[1] = 1; // b: [ 1, 1 ]
a &= b; // a: [ 1, 0, 0 ]
//! [8]
@@ -124,7 +124,7 @@ a &= b; // a: [ 1, 0, 0 ]
QBitArray a(3);
QBitArray b(2);
a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
-b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+b[0] = 1; b[1] = 1; // b: [ 1, 1 ]
a |= b; // a: [ 1, 1, 1 ]
//! [9]
@@ -133,7 +133,7 @@ a |= b; // a: [ 1, 1, 1 ]
QBitArray a(3);
QBitArray b(2);
a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
-b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+b[0] = 1; b[1] = 1; // b: [ 1, 1 ]
a ^= b; // a: [ 0, 1, 1 ]
//! [10]
@@ -151,7 +151,7 @@ QBitArray a(3);
QBitArray b(2);
QBitArray c;
a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
-b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+b[0] = 1; b[1] = 1; // b: [ 1, 1 ]
c = a & b; // c: [ 1, 0, 0 ]
//! [12]
@@ -161,7 +161,7 @@ QBitArray a(3);
QBitArray b(2);
QBitArray c;
a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
-b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+b[0] = 1; b[1] = 1; // b: [ 1, 1 ]
c = a | b; // c: [ 1, 1, 1 ]
//! [13]
@@ -171,6 +171,6 @@ QBitArray a(3);
QBitArray b(2);
QBitArray c;
a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
-b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+b[0] = 1; b[1] = 1; // b: [ 1, 1 ]
c = a ^ b; // c: [ 0, 1, 1 ]
//! [14]
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index dfa3d83fb8..b62ae30fc5 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -485,6 +485,8 @@
* N3652 Q_COMPILER_RELAXED_CONSTEXPR_FUNCTIONS
* N3386 N3638 Q_COMPILER_RETURN_TYPE_DEDUCTION
* N3651 Q_COMPILER_VARIABLE_TEMPLATES
+ *
+ * C++14 Technical Specifications / C++17:
* N3639 Q_COMPILER_VLA (see also Q_COMPILER_RESTRICTED_VLA)
*
*/
@@ -776,7 +778,6 @@
//# 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
@@ -828,13 +829,18 @@
# define Q_COMPILER_DELEGATING_CONSTRUCTORS
# define Q_COMPILER_EXPLICIT_CONVERSIONS
# define Q_COMPILER_NONSTATIC_MEMBER_INIT
-# define Q_COMPILER_INITIALIZER_LISTS
+// implemented, but nested initialization fails (eg tst_qvector): http://connect.microsoft.com/VisualStudio/feedback/details/800364/initializer-list-calls-object-destructor-twice
+// #define Q_COMPILER_INITIALIZER_LISTS
// implemented in principle, but has a bug that makes it unusable: http://connect.microsoft.com/VisualStudio/feedback/details/802058/c-11-unified-initialization-fails-with-c-style-arrays
// #define Q_COMPILER_UNIFORM_INIT
# define Q_COMPILER_RAW_STRINGS
# define Q_COMPILER_TEMPLATE_ALIAS
# define Q_COMPILER_VARIADIC_TEMPLATES
# endif /* VC 12 */
+# if _MSC_FULL_VER >= 180030324 // VC 12 SP 2 RC
+# define Q_COMPILER_INITIALIZER_LISTS
+# endif /* VC 12 SP 2 RC */
+
#endif /* Q_CC_MSVC */
#ifdef __cplusplus
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index cd422dfd87..3832e70c94 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -995,7 +995,7 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
dynamic_cast to cause a compile failure.
*/
-#ifdef QT_NO_DYNAMIC_CAST
+#if defined(QT_NO_DYNAMIC_CAST) && !defined(dynamic_cast)
# define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
template<typename T, typename X>
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index d31916abeb..a4bb8cfacb 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -500,7 +500,9 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
if (urlRef) {
QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
#ifdef Q_OS_MACX
- return QDir::cleanPath(QString(path) + QLatin1String("/Contents/") + ret);
+ QString bundleContentsDir = QString(path) + QLatin1String("/Contents/");
+ if (QDir(bundleContentsDir).exists())
+ return QDir::cleanPath(bundleContentsDir + ret);
#else
return QDir::cleanPath(QString(path) + QLatin1Char('/') + ret); // iOS
#endif
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 8c1d8b867d..da26490d18 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -64,7 +64,9 @@
#endif
#if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
+# define SD_JOURNAL_SUPPRESS_LOCATION
# include <systemd/sd-journal.h>
+# include <syslog.h>
# include <unistd.h>
#endif
@@ -1170,13 +1172,13 @@ static void systemd_default_message_handler(QtMsgType type,
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());
+ sd_journal_send("MESSAGE=%s", message.toUtf8().constData(),
+ "PRIORITY=%i", priority,
+ "CODE_FUNC=%s", context.function ? context.function : "unknown",
+ "CODE_LINE=%d", context.line,
+ "CODE_FILE=%s", context.file ? context.file : "unknown",
+ "QT_CATEGORY=%s", context.category ? context.category : "unknown",
+ NULL);
}
#endif
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index cf7ee1b7aa..384df8fd54 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -269,12 +269,12 @@
S390 is big-endian.
*/
-// #elif defined(__s390__)
-// # define Q_PROCESSOR_S390
-// # if defined(__s390x__)
-// # define Q_PROCESSOR_S390_X
-// # endif
-// # define Q_BYTE_ORDER Q_BIG_ENDIAN
+#elif defined(__s390__)
+# define Q_PROCESSOR_S390
+# if defined(__s390x__)
+# define Q_PROCESSOR_S390_X
+# endif
+# define Q_BYTE_ORDER Q_BIG_ENDIAN
/*
SuperH family, optional revision: SH-4A
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 6c0f31fb55..eabedaa80a 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -113,9 +113,10 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
&application);
if (application) {
- CFStringRef path = CFURLGetString(application);
- QString applicationPath = QCFString::toQString(path);
- if (applicationPath != QLatin1String("file://localhost/System/Library/CoreServices/Finder.app/"))
+ QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application);
+ CFStringRef identifier = CFBundleGetIdentifier(bundle);
+ QString applicationId = QCFString::toQString(identifier);
+ if (applicationId != QLatin1String("com.apple.finder"))
return true;
}
}
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 7741eb4c1e..8e3bacd6b7 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -606,7 +606,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
// FILE_INFO_BY_HANDLE_CLASS has been extended by FileIdInfo = 18 as of VS2012.
typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
-# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && _MSC_VER < 1700)
+# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
# if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
@@ -619,7 +619,7 @@ typedef struct _FILE_ID_INFO {
ULONGLONG VolumeSerialNumber;
FILE_ID_128 FileId;
} FILE_ID_INFO, *PFILE_ID_INFO;
-# endif // if defined (Q_CC_MINGW) || (defined(Q_CC_MSVC) && _MSC_VER < 1700))
+# endif // if defined (Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
// File ID for Windows up to version 7.
static inline QByteArray fileId(HANDLE handle)
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm
index bfcae2a3a2..981d663694 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.mm
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm
@@ -478,7 +478,7 @@ bool QFseventsFileSystemWatcherEngine::startStream()
NSMutableArray *pathsToWatch = [NSMutableArray arrayWithCapacity:watchedPaths.size()];
for (PathRefCounts::const_iterator i = watchedPaths.begin(), ei = watchedPaths.end(); i != ei; ++i)
- [pathsToWatch addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(i.key()))];
+ [pathsToWatch addObject:i.key().toNSString()];
struct FSEventStreamContext callBackInfo = {
0,
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index c974daab06..fb4107b95d 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -1034,7 +1034,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
LPVOID mapAddress = ::MapViewOfFile(mapHandle, access,
offsetHi, offsetLo, size + extra);
#else
- LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access, offset, size);
+ LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access,
+ (ULONG64(offsetHi) << 32) + offsetLo, size);
#endif
if (mapAddress) {
uchar *address = extra + static_cast<uchar*>(mapAddress);
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index 7e6883fd14..575150f148 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -218,11 +218,14 @@ void QLoggingSettingsParser::setContent(QTextStream &stream)
if ((equalPos != -1)
&& (line.lastIndexOf(QLatin1Char('=')) == equalPos)) {
const QStringRef pattern = line.leftRef(equalPos);
- const QStringRef value = line.midRef(equalPos + 1);
- bool enabled = (value.compare(QLatin1String("true"),
- Qt::CaseInsensitive) == 0);
- QLoggingRule rule(pattern, enabled);
- if (rule.flags != 0)
+ const QStringRef valueStr = line.midRef(equalPos + 1);
+ int value = -1;
+ if (valueStr == QLatin1String("true"))
+ value = 1;
+ else if (valueStr == QLatin1String("false"))
+ value = 0;
+ QLoggingRule rule(pattern, (value == 1));
+ if (rule.flags != 0 && (value != -1))
_rules.append(rule);
else
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index dfb897c0fd..7debf0d774 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -435,10 +435,10 @@ static inline UINT inputTimerMask()
UINT result = QS_TIMER | QS_INPUT | QS_RAWINPUT;
// QTBUG 28513, QTBUG-29097, QTBUG-29435: QS_TOUCH, QS_POINTER became part of
// QS_INPUT in Windows Kit 8. They should not be used when running on pre-Windows 8.
-#if defined(_MSC_VER) && _MSC_VER >= 1700
+#if WINVER > 0x0602
if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8)
result &= ~(QS_TOUCH | QS_POINTER);
-#endif // _MSC_VER >= 1700
+#endif // WINVER > 0x0602
return result;
}
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 623662a628..437205bf92 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -44,6 +44,7 @@
#include <QtCore/qthreadstorage.h>
#include <QtCore/qhash.h>
#include <QtCore/qstring.h>
+#include <QtCore/QThread>
QT_BEGIN_NAMESPACE
@@ -52,6 +53,11 @@ static inline QString keyBase()
return QStringLiteral("%1%2%3");
}
+static inline QByteArray threadBaseName()
+{
+ return QByteArrayLiteral("QtThread-");
+}
+
static QString qt_convertJString(jstring string)
{
QJNIEnvironmentPrivate env;
@@ -179,7 +185,10 @@ QJNIEnvironmentPrivate::QJNIEnvironmentPrivate()
{
JavaVM *vm = QtAndroidPrivate::javaVM();
if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) == JNI_EDETACHED) {
- if (vm->AttachCurrentThread(&jniEnv, 0) != JNI_OK)
+ const qulonglong id = reinterpret_cast<qulonglong>(QThread::currentThreadId());
+ const QByteArray threadName = threadBaseName() + QByteArray::number(id);
+ JavaVMAttachArgs args = { JNI_VERSION_1_6, threadName, Q_NULLPTR };
+ if (vm->AttachCurrentThread(&jniEnv, &args) != JNI_OK)
return;
}
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index e89d6396f6..43e2b5c15b 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -273,7 +273,15 @@ bool QLibraryPrivate::unload_sys()
# else
if (dlclose(pHnd)) {
# endif
+# if defined (Q_OS_QNX) // Workaround until fixed in QNX; fixes crash in
+ char *error = dlerror(); // QtDeclarative auto test "qqmlenginecleanup" for instance
+ if (!qstrcmp(error, "Shared objects still referenced")) // On QNX that's only "informative"
+ return true;
+ errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName)
+ .arg(QLatin1String(error));
+# else
errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName).arg(qdlerror());
+# endif
return false;
}
#endif
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 0f305b79af..fe5beb1c01 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -216,9 +216,9 @@ QMutex::~QMutex()
*/
void QMutex::lock() QT_MUTEX_LOCK_NOEXCEPT
{
- if (fastTryLock())
+ QMutexData *current;
+ if (fastTryLock(current))
return;
- QMutexData *current = d_ptr.loadAcquire();
if (QT_PREPEND_NAMESPACE(isRecursive)(current))
static_cast<QRecursiveMutexPrivate *>(current)->lock(-1);
else
@@ -250,9 +250,9 @@ void QMutex::lock() QT_MUTEX_LOCK_NOEXCEPT
*/
bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT
{
- if (fastTryLock())
+ QMutexData *current;
+ if (fastTryLock(current))
return true;
- QMutexData *current = d_ptr.loadAcquire();
if (QT_PREPEND_NAMESPACE(isRecursive)(current))
return static_cast<QRecursiveMutexPrivate *>(current)->lock(timeout);
else
@@ -268,9 +268,9 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT
*/
void QMutex::unlock() Q_DECL_NOTHROW
{
- if (fastTryUnlock())
+ QMutexData *current;
+ if (fastTryUnlock(current))
return;
- QMutexData *current = d_ptr.loadAcquire();
if (QT_PREPEND_NAMESPACE(isRecursive)(current))
static_cast<QRecursiveMutexPrivate *>(current)->unlock();
else
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 0bca0def22..0ecc96a9b1 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -86,6 +86,12 @@ private:
inline bool fastTryUnlock() Q_DECL_NOTHROW {
return d_ptr.testAndSetRelease(dummyLocked(), 0);
}
+ inline bool fastTryLock(QMutexData *&current) Q_DECL_NOTHROW {
+ return d_ptr.testAndSetAcquire(0, dummyLocked(), current);
+ }
+ inline bool fastTryUnlock(QMutexData *&current) Q_DECL_NOTHROW {
+ return d_ptr.testAndSetRelease(dummyLocked(), 0, current);
+ }
void lockInternal() QT_MUTEX_LOCK_NOEXCEPT;
bool lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT;
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index b0a6971964..0a2f7a9e53 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -462,7 +462,7 @@ inline int QByteArray::capacity() const
inline void QByteArray::reserve(int asize)
{
if (d->ref.isShared() || uint(asize) + 1u > d->alloc) {
- reallocData(uint(asize) + 1u, d->detachFlags() | Data::CapacityReserved);
+ reallocData(qMax(uint(size()), uint(asize)) + 1u, d->detachFlags() | Data::CapacityReserved);
} else {
// cannot set unconditionally, since d could be the shared_null or
// otherwise static
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 01faad6f2d..79365b11b1 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -559,11 +559,13 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
}
}
- // we'll read uc[offset..offset+7] (16 bytes) and c[offset-8..offset+7] (16 bytes)
+# ifdef Q_PROCESSOR_X86_64
+ enum { MaxTailLength = 7 };
+ // we'll read uc[offset..offset+7] (16 bytes) and c[offset..offset+7] (8 bytes)
if (uc + offset + 7 < e) {
- // same, but we'll throw away half the data
- __m128i chunk = _mm_loadu_si128((__m128i*)(c + offset - 8));
- __m128i secondHalf = _mm_unpackhi_epi8(chunk, nullmask);
+ // same, but we're using an 8-byte load
+ __m128i chunk = _mm_cvtsi64_si128(*(long long *)(c + offset));
+ __m128i secondHalf = _mm_unpacklo_epi8(chunk, nullmask);
__m128i ucdata = _mm_loadu_si128((__m128i*)(uc + offset));
__m128i result = _mm_cmpeq_epi16(secondHalf, ucdata);
@@ -577,6 +579,10 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
// still matched
offset += 8;
}
+# else
+ // 32-bit, we can't do MOVQ to load 8 bytes
+ enum { MaxTailLength = 15 };
+# endif
// reset uc and c
uc += offset;
@@ -584,7 +590,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
# ifdef Q_COMPILER_LAMBDA
const auto &lambda = [=](int i) { return uc[i] - ushort(c[i]); };
- return UnrollTailLoop<7>::exec(e - uc, 0, lambda, lambda);
+ return UnrollTailLoop<MaxTailLength>::exec(e - uc, 0, lambda, lambda);
# endif
#endif
@@ -5320,7 +5326,7 @@ int QString::localeAwareCompare(const QString &other) const
return localeAwareCompare_helper(constData(), length(), other.constData(), other.length());
}
-#if defined(QT_USE_ICU)
+#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined (Q_OS_MAC)
Q_GLOBAL_STATIC(QThreadStorage<QCollator>, defaultCollator)
#endif