From b0718bfaf411738dda0ca1002e78ff570ec9a342 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 1 Apr 2014 03:19:11 +0300 Subject: Fix unused variable warning > qstring.cpp:5325:1: warning: 'defaultCollator' defined > but not used [-Wunused-variable] Change-Id: I29fe2006a678f4f0b3b504b90120c0e99d7090fb Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 01faad6f2d..7d409708bb 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5320,7 +5320,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, defaultCollator) #endif -- cgit v1.2.3 From 30db2159aa54aff0c28054739e2204966c584d8c Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 1 Apr 2014 10:27:42 +0200 Subject: Fix offset calculation on WinRT According to MSDN "the offset must be a multiple of the allocation granularity". We use this already for the win32 version by splitting into offsetLo and offsetHi. However, we did not convert it back to the correct argument passed for MapViewOfFileFromApp. Now all auto-tests for mapping succeed. Task-number: QTBUG-37773 Change-Id: I7e43f906cb93164b58f4e5e3f88388cdace865d7 Reviewed-by: Andrew Knight --- src/corelib/io/qfsfileengine_win.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index c974daab06..afc8deb1a0 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1034,6 +1034,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, LPVOID mapAddress = ::MapViewOfFile(mapHandle, access, offsetHi, offsetLo, size + extra); #else + offset = (offsetHi << 32) + offsetLo; LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access, offset, size); #endif if (mapAddress) { -- cgit v1.2.3 From 5f6cbfb0701d0f4e87ac3656ffcbebdcd1577bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Fri, 28 Feb 2014 17:09:27 +0100 Subject: Android: Stop ART from complaining about missing thread names. The new Android jvm (ART) complains loudly if we attach without supplying a thread name. Task-number: QTBUG-35441 Change-Id: I962d613be0db50f3ca9a4c786b36003f31c9db14 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/kernel/qjni.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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 #include #include +#include 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(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; } -- cgit v1.2.3 From 00cfcfefb353b7157b0d206fca68bd614c558ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lisandro=20Dami=C3=A1n=20Nicanor=20P=C3=A9rez=20Meyer?= Date: Fri, 14 Mar 2014 19:19:44 -0300 Subject: Enable s390[x] detection. It has been working in Debian for some time. Change-Id: Ib5741a4ba68bf95c7020336c84bc66257ff27809 Reviewed-by: Thiago Macieira --- src/corelib/global/qprocessordetection.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib') 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 -- cgit v1.2.3 From b11adb825c4dfc8429695947cef8f9e3253ad0c2 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 17 Mar 2014 10:16:08 +0100 Subject: Logging: Be also more strict with value of logging rule Only accept lower-case "true" and "false", as documented. The old check didn't match either the documentation, nor the QSettings/ QVariant behavior (where, for a boolean value, any lower-cased content that not empty, "0" or "false" is considered true). Change-Id: I317d29c16a27f862001b9dff02e8298df8acf5a6 Reviewed-by: Friedemann Kleint Reviewed-by: Alex Blasche --- src/corelib/io/qloggingregistry.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/corelib') 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()); -- cgit v1.2.3 From 66178447e91f56eaeaee203171b9355399d3bb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 21 Mar 2014 13:48:18 +0100 Subject: Mac: Use QString::toNSString in QtBase. The string is now autoreleased. This fixes a memory leak in qt_mac_QStringListToNSMutableArrayVoid Task-number: QTBUG-20347 Change-Id: I11ebeb264af4c8ce98968f2221eea772f24c12d4 Reviewed-by: Gabriel de Dietrich Reviewed-by: Konstantin Ritt --- src/corelib/io/qfilesystemwatcher_fsevents.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') 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(QCFString::toCFStringRef(i.key()))]; + [pathsToWatch addObject:i.key().toNSString()]; struct FSEventStreamContext callBackInfo = { 0, -- cgit v1.2.3 From afacf694d5a6f34b88989e76971d70d700ce4949 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 28 Jan 2014 12:53:10 +0100 Subject: Use Finder bundle identifier over path for OS X bundle detection Currently, checking if Finder is the application returned for opening a bundle is done using its absolute path. Finder might be relocated in future OS X versions which makes this approach less clean. Using Finder's bundle identifier allows us to ignore where it is stored in the filesystem as the identifier will not change. Task-number: QTBUG-31884 Change-Id: Ib4c3412fb206fadda04eb547bc6a4eef02ee949a Reviewed-by: Oswald Buddenhagen Reviewed-by: Jake Petroules Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_unix.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib') 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 bundle = CFBundleCreate(kCFAllocatorDefault, application); + CFStringRef identifier = CFBundleGetIdentifier(bundle); + QString applicationId = QCFString::toQString(identifier); + if (applicationId != QLatin1String("com.apple.finder")) return true; } } -- cgit v1.2.3 From 10a0ac759e26e27751ae96d02eb1e260ab371194 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 2 Apr 2014 16:56:15 +0200 Subject: Windows XP target support for MSVC >= 2012 To enable windows xp support, we must do two things: 1. linker flag must be /SUBSYSTEM:CONSOLE,5.01 or /SUBSYSTEM:WINDOWS,5.01. For x64, the version is 5.02. 2. Do not use Windows Kit 8. Win SDK v7.1A is recommended. Prepend the right include paths and lib paths to INCLUDE and LIB before building. The Windows XP target support is enabled by passing "-target xp" to configure. Task-number: QTBUG-29939 Change-Id: I84c8439606cc2a9d27d64947702846faa4f1e4a2 Reviewed-by: Lucas Wang Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qfilesystemengine_win.cpp | 4 ++-- src/corelib/kernel/qeventdispatcher_win.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') 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/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index dfb897c0fd..64ad2ff0d3 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 > 0x0601 if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) result &= ~(QS_TOUCH | QS_POINTER); -#endif // _MSC_VER >= 1700 +#endif // WINVER > 0x0601 return result; } -- cgit v1.2.3 From 964ac38fb0dc84e05606b3abf6f7fcb887a62528 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Mar 2014 16:43:36 -0700 Subject: Don't read before the beginning of the string The code did discard the the data, so it wasn't affecting the comparison result (tests added anyway), but it could cause crashes if the pointer to the beginning of the data in the first 8 bytes of a page. Change-Id: I618e68de329b65de34ef8c934934c3e631cc6c9f Reported-By: Erik Verbruggen Reviewed-by: Erik Verbruggen --- src/corelib/tools/qstring.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 7d409708bb..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::exec(e - uc, 0, lambda, lambda); # endif #endif -- cgit v1.2.3 From f1540a2966ce911e9a5d5754e53f6026e3c26d22 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 24 Mar 2014 12:53:27 -0700 Subject: Fix capacity reservation for shared QByteArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can squeeze, but not by discarding elements. Make sure the size of the object stays intact after changing the reserved capacity. I've also added unit tests for other containers, just to be sure. Task-number: QTBUG-37750 Change-Id: I5135b095943b7589423c51cebcb52af792468e61 Reviewed-by: Marc Mutz Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qbytearray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') 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 -- cgit v1.2.3 From 2884d7c9aafda5ad2d84f1c7a1b4ea2625182885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 2 Apr 2014 23:16:28 +0200 Subject: OS X: Improve QLibraryInfo app bundle testing. QLibraryInfo::location() paths are relative to "myapp.app/Contents/" when the application has a bundle and relative to the executable when not. However CFBundleGetMainBundle() can and will return a valid CFBundleRef even if the application is built as a standalone executable. Add a test that verifies that the path constructed with "/Contents" exists on disk. Fall back to the non-bundle code path if it doesn't. This bug was hit in cases where a qt.conf file was present side-by-side with the app binary, for example in qtbase/bin. Task-number: QTBUG-38039 Change-Id: Id993599208fe94fff283c725778f8ad47b610ba7 Reviewed-by: Eike Ziller Reviewed-by: Gabriel de Dietrich Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qlibraryinfo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 39bfd339c3..6d25325890 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -498,7 +498,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 -- cgit v1.2.3 From 0ebfd0866d7cc9e3dabccf088d8ef1339dfe51a6 Mon Sep 17 00:00:00 2001 From: Alejandro Exojo Date: Mon, 10 Mar 2014 11:40:26 +0100 Subject: Use category names when logging to the journal Use the custom field QT_CATEGORY to store the name of the QLoggingCategory used when writing to systemd's journal. To pass custom fields sd_journal_send() is needed, and is used in combination with #define SD_JOURNAL_SUPPRESS_LOCATION to store the metadata that is already in the QMessageLogContext. Change-Id: I6a120701f7012aaa46451dd3d91586a419c5f803 Reviewed-by: Kai Koehne Reviewed-by: Thiago Macieira Reviewed-by: Robin Burchell --- src/corelib/global/qlogging.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/corelib') 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 +# include # include #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 -- cgit v1.2.3 From d84da399649d01ac689e87295f8decc024a4f8e8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Aug 2012 17:15:33 +0200 Subject: Use the new 3-operand testAndSet functions in QMutex This allows us to get the current value of the QMutex / QBasicMutex after the testAndSet operation failed. It saves an extra load from memory. Change-Id: I4922a8b3df15e342b177b13f56cf4f1184314520 Reviewed-by: Marc Mutz --- src/corelib/thread/qmutex.cpp | 12 ++++++------ src/corelib/thread/qmutex.h | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/corelib') 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(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(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(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 *¤t) Q_DECL_NOTHROW { + return d_ptr.testAndSetAcquire(0, dummyLocked(), current); + } + inline bool fastTryUnlock(QMutexData *¤t) Q_DECL_NOTHROW { + return d_ptr.testAndSetRelease(dummyLocked(), 0, current); + } void lockInternal() QT_MUTEX_LOCK_NOEXCEPT; bool lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT; -- cgit v1.2.3 From e30ae1268f8e224369ff7841b90184c8694a86e7 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 7 Apr 2014 10:42:48 +0200 Subject: fix build for MSVC 2010 The Windows version for QS_TOUCH and QS_POINTER was slightly off. Change-Id: Idb8a8219e09c6aa1a1b24e45b9da640c8d4b7161 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/kernel/qeventdispatcher_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 64ad2ff0d3..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 WINVER > 0x0601 +#if WINVER > 0x0602 if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) result &= ~(QS_TOUCH | QS_POINTER); -#endif // WINVER > 0x0601 +#endif // WINVER > 0x0602 return result; } -- cgit v1.2.3 From c33849d0cbfbe0c33170d8e3a49f89b22fd76246 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 7 Apr 2014 13:49:17 -0700 Subject: Don't redefine dynamic_cast if it's already a macro Redefining macros is always a bad idea. On top of that, MSVC doesn't like when we #define dynamic_cast, even though the C++ standard explicitly allows it. Task-number: QTBUG-29093 Change-Id: I6e33d609ce213cf6a9085faa3f991a873d825dc6 Reviewed-by: Olivier Goffart --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 9b5d78b6fe..fba8b019e7 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -980,7 +980,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 -- cgit v1.2.3 From fbeb43135feadbdfcd48b6717b5cb4017325cd1d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 4 Mar 2014 23:19:17 -0800 Subject: Mark Variable Length Arrays as a TS feature for C++14 The feature was removed from the C++14 draft standard and moved instead to a Technical Specification. Since we don't know how to enable TS features in GCC 4.9 yet, remove it from the definition. The Clang definition is probably safe, since it is behind an #if __has_extension. Change-Id: Ibc32b35657b046680078b39a7678bd8e1e5395d2 Reviewed-by: Olivier Goffart Reviewed-by: Marc Mutz --- src/corelib/global/qcompilerdetection.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 6755b82f61..00f209ad6d 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -483,6 +483,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) * */ @@ -774,7 +776,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 -- cgit v1.2.3 From 5fe98ebb376bcbc8728e4ce64b697637404a55e1 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Sun, 6 Apr 2014 20:00:07 -0500 Subject: Prevent QUnifiedTimer from ticking backwards. This could happen in the following situation: * a custom animation driver with fixed delta * a triple-buffering scheme (rendering ahead a frame) * a second animation timer starting while a first was active This would cause QUnifiedTimer::startTimers() to trigger QUnifiedTimer::updateAnimationTimers(-1), and use the current time from the QElapsedTimer rather than the animation driver. This time could be less than the last reported time from the animation driver. Change-Id: Ibf1796fcb99f288d4946b30e5e7225695aa61781 Reviewed-by: Gunnar Sletta --- src/corelib/animation/qabstractanimation.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/corelib') 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); -- cgit v1.2.3 From 670ebed1214ed0dae9a52ab40c5b5065c7d02a35 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 4 Apr 2014 11:51:16 +0200 Subject: Fix out-of-range shifting offsetHi needs to be casted first before shifting. Change-Id: I29c773dd13d5b16042629604015bbf5645fab861 Reviewed-by: Andrew Knight --- src/corelib/io/qfsfileengine_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index afc8deb1a0..fb4107b95d 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1034,8 +1034,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, LPVOID mapAddress = ::MapViewOfFile(mapHandle, access, offsetHi, offsetLo, size + extra); #else - offset = (offsetHi << 32) + offsetLo; - 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(mapAddress); -- cgit v1.2.3 From 4af257eb3cfeef93adefda5f981742ffb58ba0ad Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Tue, 8 Apr 2014 09:38:28 +0200 Subject: QNX: Work around dlclose issue "Shared objects still referenced" dlerror should actually be treated as "for your information" only, not as an actual error. Change-Id: Ie02bd1db0dd2dc93bb759f8b6c7e825070e17bb9 Reviewed-by: Fabian Bumberger --- src/corelib/plugin/qlibrary_unix.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/corelib') 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 -- cgit v1.2.3 From 71de8c0df57ddee94da71fab4a613f1df003a18f Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 9 Apr 2014 05:25:58 -0700 Subject: Only define Q_COMPILER_INITIALIZER_LISTS for MSVC 12 SP 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nested initialization is broken before SP2, so just disable the whole feature as tst_qvector crashes(release)/fails(debug) Done-with: Jedrzej Nowacki Task-number: QTBUG-38186 Change-Id: I9c5c9e55c75854fc1f05a59fab2ac7dce9b37fbb Reviewed-by: Jędrzej Nowacki Reviewed-by: Friedemann Kleint --- src/corelib/global/qcompilerdetection.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 00f209ad6d..950647004a 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -827,13 +827,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 -- cgit v1.2.3 From 8a96e0d83c6493e66502b6c500d8fdf6eb0090ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 8 Apr 2014 16:31:18 +0000 Subject: Fix a typo in QBitArray documentation Task-number: QTBUG-37839 Change-Id: Id55d2d606b93f7f9e58ef423544e42b548035ee3 Reviewed-by: Friedemann Kleint --- .../doc/snippets/code/src_corelib_tools_qbitarray.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib') 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] -- cgit v1.2.3