From e1d0da65261077bfd720887d6e6216497abb4c5f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Apr 2016 12:36:28 -0700 Subject: Fix Clang -Wexpansion-to-defined warning by deprecating QT_SUPPORTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C and C++ standards say it's undefined whether the preprocessor supports macros that expand to defined() will operate as an ifdef. Clang 3.9 started complaining about that fact. One solution was to change QT_SUPPORTS to check for zero or one, which means we need to change the #defines QT_NO_xxx to #define QT_NO_xxx 1. The C standard says we don't need to #define to 0, as an unknown token is interpreted as zero. However, that might produce a warning (GCC with -Wundef), so changing the macro this way is not recommended. Instead, we deprecate the macro and replace the uses with #ifdef/ndef. Change-Id: Id75834dab9ed466e94c7ffff1444874d5680b96a Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 3 +++ src/corelib/tools/qarraydata.cpp | 6 +++--- src/corelib/tools/qarraydata.h | 4 ++-- src/corelib/tools/qarraydatapointer.h | 2 +- src/corelib/tools/qcontiguouscache.h | 2 +- src/corelib/tools/qhash.h | 2 +- src/corelib/tools/qlinkedlist.h | 2 +- src/corelib/tools/qlist.h | 2 +- src/corelib/tools/qmap.h | 2 +- src/corelib/tools/qrefcount.h | 6 +++--- src/corelib/tools/qset.h | 2 +- src/corelib/tools/qvector.h | 8 ++++---- 12 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 5bb1ce77bd..a7183cb983 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -55,6 +55,9 @@ #include #endif +// The QT_SUPPORTS macro is deprecated. Don't use it in new code. +// Instead, use #ifdef/ndef QT_NO_feature. +// ### Qt6: remove macro #ifdef _MSC_VER # define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE) #else diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index fa6556f7d9..eb6ce21282 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -65,7 +65,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, // Don't allocate empty headers if (!(options & RawData) && !capacity) { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (options & Unsharable) return const_cast(&qt_array_unsharable_empty); #endif @@ -110,7 +110,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) header->ref.atomic.store(bool(!(options & Unsharable))); #else header->ref.atomic.store(1); @@ -132,7 +132,7 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize, && !(alignment & (alignment - 1))); Q_UNUSED(objectSize) Q_UNUSED(alignment) -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (data == &qt_array_unsharable_empty) return; #endif diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 865bd4325d..cbbfe1bea2 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -72,7 +72,7 @@ struct Q_CORE_EXPORT QArrayData enum AllocationOption { CapacityReserved = 0x1, -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Unsharable = 0x2, #endif RawData = 0x4, @@ -249,7 +249,7 @@ struct QTypedArrayData return allocate(/* capacity */ 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) static QTypedArrayData *unsharableEmpty() { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 9804d2c2d5..615d7c5f80 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -127,7 +127,7 @@ public: return (!d->isMutable() || d->ref.isShared()); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) void setSharable(bool sharable) { if (needsDetach()) { diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 41d198f9bc..d546e949c2 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -96,7 +96,7 @@ public: inline void detach() { if (d->ref.load() != 1) detach_helper(); } inline bool isDetached() const { return d->ref.load() == 1; } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } #endif diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index a18dd74706..a5bde40fb8 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -266,7 +266,7 @@ public: inline void detach() { if (d->ref.isShared()) detach_helper(); } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QHashData::shared_null) d->sharable = sharable; } #endif bool isSharedWith(const QHash &other) const { return d == other.d; } diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 110529d843..710bf5a9f2 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -99,7 +99,7 @@ public: inline void detach() { if (d->ref.isShared()) detach_helper2(this->e); } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QLinkedListData::shared_null) d->sharable = sharable; } #endif inline bool isSharedWith(const QLinkedList &other) const { return d == other.d; } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index e04a6be1ab..381875e96f 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -169,7 +169,7 @@ public: } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (sharable == d->ref.isSharable()) diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index ed49e70f4e..7b5a643a1e 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -359,7 +359,7 @@ public: inline void detach() { if (d->ref.isShared()) detach_helper(); } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (sharable == d->ref.isSharable()) diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index a390989e76..bff6885d65 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -47,7 +47,7 @@ class RefCount public: inline bool ref() Q_DECL_NOTHROW { int count = atomic.load(); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable return false; #endif @@ -58,7 +58,7 @@ public: inline bool deref() Q_DECL_NOTHROW { int count = atomic.load(); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable return false; #endif @@ -67,7 +67,7 @@ public: return atomic.deref(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) bool setSharable(bool sharable) Q_DECL_NOTHROW { Q_ASSERT(!isShared()); diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 3f4208e8b3..7e7eb5210c 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -79,7 +79,7 @@ public: inline void detach() { q_hash.detach(); } inline bool isDetached() const { return q_hash.isDetached(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { q_hash.setSharable(sharable); } #endif diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 691872cb36..3154220634 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -100,7 +100,7 @@ public: inline void detach(); inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (sharable == d->ref.isSharable()) @@ -376,7 +376,7 @@ template void QVector::detach() { if (!isDetached()) { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (!d->alloc) d = Data::unsharableEmpty(); else @@ -533,7 +533,7 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo x = Data::allocate(aalloc, options); Q_CHECK_PTR(x); // aalloc is bigger then 0 so it is not [un]sharedEmpty -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Q_ASSERT(x->ref.isSharable() || options.testFlag(QArrayData::Unsharable)); #endif Q_ASSERT(!x->ref.isStatic()); @@ -601,7 +601,7 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo Q_ASSERT(d->data()); Q_ASSERT(uint(d->size) <= d->alloc); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Q_ASSERT(d != Data::unsharableEmpty()); #endif Q_ASSERT(aalloc ? d != Data::sharedNull() : d == Data::sharedNull()); -- cgit v1.2.3 From 29076cf6cbd22e2e16a730787c79c2734655756e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 29 Apr 2016 20:52:05 -0700 Subject: Fix QBasicAtomicPointer::{load,store} to actually be relaxed We were using direct loading and operator=, which for everything except std::atomic was very relaxed. But std::atomic defines the direct access to actually be the least relaxed possible, under the idea that if you didn't know any better to use a member function, you probably need the most protection. So use Ops::load and Ops::store. Change-Id: Id5480807d25e49e78b79ffff144a06a2e6398576 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/thread/qbasicatomic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index c29b80d3d0..7960174277 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -249,8 +249,8 @@ public: AtomicType _q_value; - Type load() const Q_DECL_NOTHROW { return _q_value; } - void store(Type newValue) Q_DECL_NOTHROW { _q_value = newValue; } + Type load() const Q_DECL_NOTHROW { return Ops::load(_q_value); } + void store(Type newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); } operator Type() const Q_DECL_NOTHROW { return loadAcquire(); } Type operator=(Type newValue) Q_DECL_NOTHROW { storeRelease(newValue); return newValue; } -- cgit v1.2.3 From b168c6c8248662da31dbaaf2afb8e771a9ecdc85 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 22:21:53 -0800 Subject: QStorageInfo: fix matching of mountpoints to sibling directories The path "/usrfoo" starts with "/usr", so if you tried to get QStorageInfo("/usrfoo") when "/usr" is a mount point, you'd get the wrong filesystem. [ChangeLog][QtCore][QStorageInfo] Fixed a bug that caused QStorageInfo to report information for the wrong filesystem if there is a mounted filesystem at a path that is a prefix of the requested path (e.g., it would report "/usr" filesystem for "/usrfoo"). Task-number: QTBUG-49498 Change-Id: I3e15a26e0e424169ac2bffff1417b7a27cd0132d Reviewed-by: Jake Petroules --- src/corelib/io/qstorageinfo_unix.cpp | 58 +++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index e365d8d7e6..bbcc29c50b 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -102,25 +102,6 @@ QT_BEGIN_NAMESPACE -static bool isPseudoFs(const QString &mountDir, const QByteArray &type) -{ - if (mountDir.startsWith(QLatin1String("/dev")) - || mountDir.startsWith(QLatin1String("/proc")) - || mountDir.startsWith(QLatin1String("/sys")) - || mountDir.startsWith(QLatin1String("/var/run")) - || mountDir.startsWith(QLatin1String("/var/lock"))) { - return true; - } - if (type == "tmpfs") - return true; -#if defined(Q_OS_LINUX) - if (type == "rootfs" || type == "rpc_pipefs") - return true; -#endif - - return false; -} - class QStorageIterator { public: @@ -158,6 +139,36 @@ private: #endif }; +template +static bool isParentOf(const String &parent, const QString &dirName) +{ + return dirName.startsWith(parent) && + (dirName.size() == parent.size() || dirName.at(parent.size()) == QLatin1Char('/') || + parent.size() == 1); +} + +static bool isPseudoFs(const QStorageIterator &it) +{ + QString mountDir = it.rootPath(); + if (isParentOf(QLatin1String("/dev"), mountDir) + || isParentOf(QLatin1String("/proc"), mountDir) + || isParentOf(QLatin1String("/sys"), mountDir) + || isParentOf(QLatin1String("/var/run"), mountDir) + || isParentOf(QLatin1String("/var/lock"), mountDir)) { + return true; + } + + QByteArray type = it.fileSystemType(); + if (type == "tmpfs") + return true; +#if defined(Q_OS_LINUX) + if (type == "rootfs" || type == "rpc_pipefs") + return true; +#endif + + return false; +} + #if defined(Q_OS_BSD4) inline QStorageIterator::QStorageIterator() @@ -444,10 +455,10 @@ void QStorageInfoPrivate::initRootPath() while (it.next()) { const QString mountDir = it.rootPath(); const QByteArray fsName = it.fileSystemType(); - if (isPseudoFs(mountDir, fsName)) + if (isPseudoFs(it)) continue; // we try to find most suitable entry - if (oldRootPath.startsWith(mountDir) && maxLength < mountDir.length()) { + if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.length()) { maxLength = mountDir.length(); rootPath = mountDir; device = it.device(); @@ -536,11 +547,10 @@ QList QStorageInfoPrivate::mountedVolumes() QList volumes; while (it.next()) { - const QString mountDir = it.rootPath(); - const QByteArray fsName = it.fileSystemType(); - if (isPseudoFs(mountDir, fsName)) + if (isPseudoFs(it)) continue; + const QString mountDir = it.rootPath(); volumes.append(QStorageInfo(mountDir)); } -- cgit v1.2.3 From d9f6b6d1f836c25a8179ae7a6df18ee9cceebfb1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 22:25:04 -0800 Subject: QStorageInfo: update the detection of pseudo filesystems Allow tmpfs filesystems to be reported, as they're often usable by the user, mounted in /tmp and in /run (the fs for $XDG_RUNTIME_DIR). But disallow anything whose device is not a pathname. This catches most of everything else that wasn't specifically tested for before, like virtual fuse filesystems, like GVFS. Change-Id: I3e15a26e0e424169ac2bffff1417b7cee0f8ec97 Reviewed-by: Ivan Komissarov Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index bbcc29c50b..bf998993d8 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -160,12 +160,15 @@ static bool isPseudoFs(const QStorageIterator &it) QByteArray type = it.fileSystemType(); if (type == "tmpfs") - return true; + return false; #if defined(Q_OS_LINUX) if (type == "rootfs" || type == "rpc_pipefs") return true; #endif + if (!it.device().startsWith('/')) + return true; + return false; } -- cgit v1.2.3 From 4aba3dbcb3832cb70253b7100e2a8555261a69c8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 22:54:19 -0800 Subject: QStorageInfo: get the label properly if the mounted device is a symlink This happens for me with LVM: $ ls -l /dev/mapper/system-root /dev/system/root /dev/disk/by-label/* lrwxrwxrwx 1 root root 10 Nov 17 22:45 /dev/disk/by-label/system -> ../../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/mapper/system-root -> ../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/system/root -> ../dm-1 The mounted device according to /etc/mtab (/proc/self/mounts) is /dev/mapper/system-root. Change-Id: I3e15a26e0e424169ac2bffff1417b96779d84246 Reviewed-by: Ivan Komissarov Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index bf998993d8..bf33c160fc 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -475,11 +475,14 @@ static inline QString retrieveLabel(const QByteArray &device) #ifdef Q_OS_LINUX static const char pathDiskByLabel[] = "/dev/disk/by-label"; + QFileInfo devinfo(QFile::decodeName(device)); + QString devicePath = devinfo.canonicalFilePath(); + QDirIterator it(QLatin1String(pathDiskByLabel), QDir::NoDotAndDotDot); while (it.hasNext()) { it.next(); QFileInfo fileInfo(it.fileInfo()); - if (fileInfo.isSymLink() && fileInfo.symLinkTarget().toLocal8Bit() == device) + if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath) return fileInfo.fileName(); } #elif defined Q_OS_HAIKU -- cgit v1.2.3 From 0453897f1ee1cdf6dc216bec975a198e386428e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 23:07:49 -0800 Subject: QStorageInfo: allow getting the info of pseudo filesystems too They won't be listed in QStorageInfo::mountedVolumes, but we can now obtain their info if you know their mountpoint. For example, on Linux: $ ./qstorageinfo /dev /proc /sys Filesystem (Type) Size Available BSize Label Mounted on devtmpfs (devtmpfs) RW 4029772 4029764 4096 /dev proc (proc) RW 0 0 4096 /proc sysfs (sysfs) RW 0 0 4096 /sys Change-Id: I3e15a26e0e424169ac2bffff1417ba2429d6d9f4 Reviewed-by: Ivan Komissarov Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index bf33c160fc..1d1b2907b7 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -458,8 +458,6 @@ void QStorageInfoPrivate::initRootPath() while (it.next()) { const QString mountDir = it.rootPath(); const QByteArray fsName = it.fileSystemType(); - if (isPseudoFs(it)) - continue; // we try to find most suitable entry if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.length()) { maxLength = mountDir.length(); -- cgit v1.2.3 From 8edfc4e9b61d7029e90423b4e5daca87fb5a82b8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 4 May 2016 16:08:37 +0200 Subject: make zlib_dependency auto-add QtCore as a private dep our zlib header includes qglobal.h, so we need the qtcore include dirs, and qtcore is also where the actual code is compiled into. Change-Id: I09f530a1b4e6160438215a6d7223c0771ce94f05 Reviewed-by: Simon Hausmann --- src/corelib/tools/tools.pri | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index ed6afe70ce..bf4c6e2912 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -158,6 +158,7 @@ else:SOURCES += tools/qelapsedtimer_generic.cpp contains(QT_CONFIG, zlib) { include($$PWD/../../3rdparty/zlib.pri) } else { + CONFIG += no_core_dep include($$PWD/../../3rdparty/zlib_dependency.pri) } -- cgit v1.2.3 From 81793b8b58cde01e52675093dc378147dc2102e3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 May 2016 10:49:11 +0200 Subject: Add QT_NO_FOREACH to disable foreach and Q_FOREACH It has been known for a long time that Q_FOREACH produces inferior code to other looping constructs, and the use of it in Qt library code was informally frowned upon since forever (pun intended). Yet, to this day, several thousand foreach/Q_FOREACH loops have been added to Qt libraries, and while many were ported to range-for in Qt 5.7, there are still new ones added every day, which is a nuisance, to say the least. This patch introduces a technical way to prevent new foreach use to creep into Qt libraries after they have been cleaned, by simply not defining either Q_FOREACH or foreach when the QT_NO_FOREACH macro is defined. This way, one library at a time can be ported away, and, once ported, is guaranteed to actually stay ported. Change-Id: Ie042e84d6c7d766bd16095f9bc1118a8e0ce0c7a Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index a72bdb4d59..e35ee0987f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -932,6 +932,8 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic # endif #endif +#ifndef QT_NO_FOREACH + template class QForeachContainer { QForeachContainer &operator=(const QForeachContainer &) Q_DECL_EQ_DELETE; @@ -957,11 +959,15 @@ for (QForeachContainer ++_container_.i, _container_.control ^= 1) \ for (variable = *_container_.i; _container_.control; _container_.control = 0) +#endif // QT_NO_FOREACH + #define Q_FOREVER for(;;) #ifndef QT_NO_KEYWORDS +# ifndef QT_NO_FOREACH # ifndef foreach # define foreach Q_FOREACH # endif +# endif // QT_NO_FOREACH # ifndef forever # define forever Q_FOREVER # endif -- cgit v1.2.3 From e2e0dfee7c675c91132197b4a01a394a5da9a36f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 May 2016 11:53:02 +0200 Subject: QtCore/QtDBus/QtSql: port the last remaining Q_FOREACH loop and add QT_NO_FOREACH Port the last remaining Q_FOREACH user in QtCore to C++11 range-for and mark QtCore, QtSql and QtDBus as Q_FOREACH-free, using QT_NO_FOREACH. Change-Id: Ia6f99139cb1ca4a8bbe9e445421592242e048b0a Reviewed-by: Thiago Macieira --- src/corelib/corelib.pro | 2 +- src/corelib/statemachine/qstatemachine.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 362ac37a59..42fd5d1a61 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -8,7 +8,7 @@ MODULE_CONFIG = moc resources CONFIG += $$MODULE_CONFIG DEFINES += $$MODULE_DEFINES -DEFINES += QT_NO_USING_NAMESPACE +DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x67000000 irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index d5b01f3c8a..e3cfd7b988 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1778,7 +1778,11 @@ void QStateMachinePrivate::_q_start() { Q_Q(QStateMachine); Q_ASSERT(state == Starting); - foreach (QAbstractState *state, configuration) { + // iterate over a copy, since we emit signals which may cause + // 'configuration' to change, resulting in undefined behavior when + // iterating at the same time: + const auto config = configuration; + for (QAbstractState *state : config) { QAbstractStatePrivate *abstractStatePrivate = QAbstractStatePrivate::get(state); abstractStatePrivate->active = false; emit state->activeChanged(false); -- cgit v1.2.3 From 9ef59b586d6c65404835c5003a0f486ef9e162c3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 29 Apr 2016 21:39:44 -0700 Subject: QMutex: make FUTEX_PRIVATE_FLAG a mandatory feature The flag was introduced in kernel 2.6.22, but we're already depending on features added on 2.6.23 in qcore_unix_p.h (pipe2, dup3, O_CLOEXEC) and 2.6.27 in qnet_unix_p.h (accept4 and SOCK_CLOEXEC). Change-Id: Id5480807d25e49e78b79ffff144a093c9e30cd96 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/corelib/thread/qmutex_linux.cpp | 41 ++++++------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 89eb3da203..25444ffff6 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -56,6 +56,11 @@ # error "Qt build is broken: qmutex_linux.cpp is being built but futex support is not wanted" #endif +#ifndef FUTEX_PRIVATE_FLAG +# define FUTEX_PRIVATE_FLAG 128 +#endif + + QT_BEGIN_NAMESPACE /* @@ -104,40 +109,6 @@ QT_BEGIN_NAMESPACE static QBasicAtomicInt futexFlagSupport = Q_BASIC_ATOMIC_INITIALIZER(-1); -static int checkFutexPrivateSupport() -{ - int value = 0; -#if defined(FUTEX_PRIVATE_FLAG) - // check if the kernel supports extra futex flags - // FUTEX_PRIVATE_FLAG appeared in v2.6.22 - Q_STATIC_ASSERT(FUTEX_PRIVATE_FLAG != 0x80000000); - - // try an operation that has no side-effects: wake up 42 threads - // futex will return -1 (errno==ENOSYS) if the flag isn't supported - // there should be no other error conditions - value = syscall(__NR_futex, &futexFlagSupport, - FUTEX_WAKE | FUTEX_PRIVATE_FLAG, - 42, 0, 0, 0); - if (value != -1) - value = FUTEX_PRIVATE_FLAG; - else - value = 0; - -#else - value = 0; -#endif - futexFlagSupport.store(value); - return value; -} - -static inline int futexFlags() -{ - int value = futexFlagSupport.load(); - if (Q_LIKELY(value != -1)) - return value; - return checkFutexPrivateSupport(); -} - static inline int _q_futex(void *addr, int op, int val, const struct timespec *timeout) Q_DECL_NOTHROW { volatile int *int_addr = reinterpret_cast(addr); @@ -149,7 +120,7 @@ static inline int _q_futex(void *addr, int op, int val, const struct timespec *t // we use __NR_futex because some libcs (like Android's bionic) don't // provide SYS_futex etc. - return syscall(__NR_futex, int_addr, op | futexFlags(), val, timeout, addr2, val2); + return syscall(__NR_futex, int_addr, op | FUTEX_PRIVATE_FLAG, val, timeout, addr2, val2); } static inline QMutexData *dummyFutexValue() -- cgit v1.2.3 From feaef445591e9028c1ad41f33f7f2daae5f31f70 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 May 2016 08:46:13 +0200 Subject: Windows: Suppress error dialogs when querying logical drives. Set the error mode flag SEM_NOOPENFILEERRORBOX when calling Win32 API GetLogicalDrives() to prevent it from prompting to insert media as does QStorageInfoPrivate::mountedVolumes(). Task-number: QTBUG-18729 Task-number: QTBUG-32457 Change-Id: I5c76afbb5bf2ec5ec84194650c316fe531578d5b Reviewed-by: Oliver Wolff --- src/corelib/io/qfilesystemengine_win.cpp | 2 ++ src/corelib/io/qfsfileengine_win.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index e55ab0b544..257bd4a50e 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -879,7 +879,9 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa #if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) if (fname.isDriveRoot()) { // a valid drive ?? + const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); DWORD drivesBitmask = ::GetLogicalDrives(); + ::SetErrorMode(oldErrorMode); int drivebit = 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode()); if (drivesBitmask & drivebit) { fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 886d526fb1..689251a6c7 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -626,7 +626,9 @@ QFileInfoList QFSFileEngine::drives() QFileInfoList ret; #if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #if defined(Q_OS_WIN32) + const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); quint32 driveBits = (quint32) GetLogicalDrives() & 0x3ffffff; + ::SetErrorMode(oldErrorMode); #endif char driveName[] = "A:/"; -- cgit v1.2.3 From 72e3fcce387d72043dd0b9fbe06d6b720861c1e7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 10 May 2016 14:54:24 +0200 Subject: Doc: Remove repository name from examplesinstallpath Examples in binary packages now directly match the install path. Change-Id: Ic1487bc766cfd3b0a0a340cc4ae4ba49d953eaa6 Task-number: QTBUG-52953 Reviewed-by: Oswald Buddenhagen --- src/corelib/doc/qtcore.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index e98f06d47d..3d64708def 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -4,7 +4,7 @@ project = QtCore description = Qt Core Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/corelib +examplesinstallpath = corelib qhp.projects = QtCore -- cgit v1.2.3 From d6fbb9070f518443f7ebeb0eae53847814e2496b Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Mon, 9 May 2016 16:42:11 +0200 Subject: Doc: Remove references to obsolete reset() function ...from the docs of the signals it emits. Task-number: QTBUG-53228 Change-Id: Ifdd91404cae9dd6480ae29b31f2a48fa024df442 Reviewed-by: Nico Vertriest --- src/corelib/itemmodels/qabstractitemmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 90297b9115..630cdcae98 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3653,7 +3653,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti \fn QAbstractItemModel::modelAboutToBeReset() \since 4.2 - This signal is emitted when reset() is called, before the model's internal + This signal is emitted when beginResetModel() is called, before the model's internal state (e.g. persistent model indexes) has been invalidated. \sa beginResetModel(), modelReset() @@ -3663,7 +3663,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti \fn QAbstractItemModel::modelReset() \since 4.1 - This signal is emitted when reset() or endResetModel() is called, after the + This signal is emitted when endResetModel() is called, after the model's internal state (e.g. persistent model indexes) has been invalidated. Note that if a model is reset it should be considered that all information -- cgit v1.2.3 From 4dc29bc9de1da1d373962dbd4b1d232f38ffeee0 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 12 May 2016 12:33:04 +0200 Subject: QSharedPointer: move QDebug stream operators into qdebug.h In order to avoid pulling in QDebug when including QSharedPointer. Change-Id: I14b86d1f100ed44a68258c91bbda394b655bac83 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/io/qdebug.cpp | 11 +++++++++++ src/corelib/io/qdebug.h | 9 +++++++++ src/corelib/tools/qsharedpointer.cpp | 11 ----------- src/corelib/tools/qsharedpointer.h | 2 -- src/corelib/tools/qsharedpointer_impl.h | 11 ----------- 5 files changed, 20 insertions(+), 24 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index ffa7867d18..0d9fdb3453 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -793,6 +793,17 @@ QDebug &QDebug::resetFormat() Writes \a flag to \a stream. */ +/*! + \fn QDebug operator<<(QDebug debug, const QSharedPointer &ptr) + \relates QSharedPointer + \since 5.7 + + Writes the pointer tracked by \a ptr into the debug object \a debug for + debugging purposes. + + \sa {Debugging Techniques} +*/ + /*! \class QDebugStateSaver \inmodule QtCore diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 5087e3b532..8021f29e16 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -51,6 +51,7 @@ #include #include #include +#include // all these have already been included by various headers above, but don't rely on indirect includes: #include @@ -330,6 +331,14 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) return debug.maybeSpace(); } +template +inline QDebug operator<<(QDebug debug, const QSharedPointer &ptr) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QSharedPointer(" << ptr.data() << ")"; + return debug; +} + Q_CORE_EXPORT void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, int value); template diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index d03e3129aa..84afb0c5db 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1299,17 +1299,6 @@ compile. Use qSharedPointerConstCast to cast away the constness. */ -/*! - \fn QDebug operator<<(QDebug debug, const QSharedPointer &ptr) - \relates QSharedPointer - \since 5.7 - - Writes the pointer tracked by \a ptr into the debug object \a debug for - debugging purposes. - - \sa {Debugging Techniques} -*/ - #include #include diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index 901862e7a2..72976637d5 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -159,8 +159,6 @@ template QSharedPointer qSharedPointerObjectCast(const QWe template QWeakPointer qWeakPointerCast(const QWeakPointer &src); -template QDebug operator<<(QDebug debug, const QSharedPointer &ptr); - QT_END_NAMESPACE #endif // Q_QDOC diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 6a5c8f4fe5..e9a5443121 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -62,7 +62,6 @@ QT_END_NAMESPACE #include #include #include // for qobject_cast -#include #if QT_DEPRECATED_SINCE(5, 6) #include #endif @@ -877,16 +876,6 @@ inline void qSwap(QSharedPointer &p1, QSharedPointer &p2) p1.swap(p2); } -#ifndef QT_NO_DEBUG_STREAM -template -Q_INLINE_TEMPLATE QDebug operator<<(QDebug debug, const QSharedPointer &ptr) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QSharedPointer(" << ptr.data() << ")"; - return debug; -} -#endif - QT_END_NAMESPACE namespace std { template -- cgit v1.2.3 From c9998b8af39bcf990f4ef9a0ff87b65574a86bfd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 9 May 2016 11:19:27 -0700 Subject: Fix build with GCC <= 4.2 (FreeBSD 9.x) 15b42af11123f9d1eb4bbd79870185585103ea8d changed the qt_cpu_features variable to be an array and never fixed this #if branch of the code. Change-Id: Id69569111e7d4e619e22ffff144cf930f86f478e Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qsimd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 5ca2ce4c6f..a1ee5b6348 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -666,7 +666,11 @@ void qDetectCpuFeatures() // contains all the features that the code required. Qt 4 ran for years // like that, so it shouldn't be a problem. - qt_cpu_features.store(minFeature | quint32(QSimdInitialized)); + qt_cpu_features[0].store(minFeature | quint32(QSimdInitialized)); +#ifndef Q_ATOMIC_INT64_IS_SUPPORTED + qt_cpu_features[1].store(minFeature >> 32); +#endif + return; # endif #endif -- cgit v1.2.3 From 432d3b696296db9131bfa3daa67285f0eaedec41 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 29 Apr 2016 14:52:28 +0300 Subject: QDateTimeParser: use QStringRef more Avoid unnecessary allocations. Change-Id: I217ba3fe20293f5cdeeaac2dfae15f837cda51e0 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetimeparser.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 8ddf1d9e41..cc8c08d5b1 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -713,7 +713,7 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde QDTPDEBUG << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectiontext - << text.mid(index, sectionmaxsize) + << text.midRef(index, sectionmaxsize) << index; int used = 0; @@ -743,9 +743,8 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde QDTPDEBUGN("This should never happen (findAmPm returned %d)", ampm); break; } - if (state != Invalid) { - text.replace(index, used, sectiontext.left(used)); - } + if (state != Invalid) + text.replace(index, used, sectiontext.constData(), used); break; } case MonthSection: case DayOfWeekSectionShort: @@ -764,7 +763,7 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde if (num != -1) { state = (used == sectiontext.size() ? Acceptable : Intermediate); - text.replace(index, used, sectiontext.left(used)); + text.replace(index, used, sectiontext.constData(), used); } else { state = Intermediate; } @@ -810,7 +809,7 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde } } if (ok && tmp <= absMax) { - QDTPDEBUG << sectiontext.left(digits) << tmp << digits; + QDTPDEBUG << sectiontext.leftRef(digits) << tmp << digits; last = tmp; used = digits; break; @@ -911,7 +910,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos for (int index=0; state != Invalid && index @@ -1193,6 +1194,89 @@ void QMessagePattern::setPattern(const QString &pattern) memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*)); } +#if defined(QLOGGING_HAVE_BACKTRACE) && !defined(QT_BOOTSTRAPPED) +// make sure the function has "Message" in the name so the function is removed + +#if (defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || QT_HAS_ATTRIBUTE(optimize) +// force skipping the frame pointer, to save the backtrace() function some work +__attribute__((optimize("omit-frame-pointer"))) +#endif +static QStringList backtraceFramesForLogMessage(int frameCount) +{ + QStringList result; + if (frameCount == 0) + return result; + + // The results of backtrace_symbols looks like this: + // /lib/libc.so.6(__libc_start_main+0xf3) [0x4a937413] + // The offset and function name are optional. + // This regexp tries to extract the library name (without the path) and the function name. + // This code is protected by QMessagePattern::mutex so it is thread safe on all compilers + static QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"), + QRegularExpression::OptimizeOnFirstUsageOption); + + QVarLengthArray buffer(7 + frameCount); + int n = backtrace(buffer.data(), buffer.size()); + if (n > 0) { + int numberPrinted = 0; + for (int i = 0; i < n && numberPrinted < frameCount; ++i) { + QScopedPointer strings(backtrace_symbols(buffer.data() + i, 1)); + QString trace = QString::fromLatin1(strings.data()[0]); + QRegularExpressionMatch m = rx.match(trace); + if (m.hasMatch()) { + QString library = m.captured(1); + QString function = m.captured(2); + + // skip the trace from QtCore that are because of the qDebug itself + if (!numberPrinted && library.contains(QLatin1String("Qt5Core")) + && (function.isEmpty() || function.contains(QLatin1String("Message"), Qt::CaseInsensitive) + || function.contains(QLatin1String("QDebug")))) { + continue; + } + + if (function.startsWith(QLatin1String("_Z"))) { + QScopedPointer demangled( + abi::__cxa_demangle(function.toUtf8(), 0, 0, 0)); + if (demangled) + function = QString::fromUtf8(qCleanupFuncinfo(demangled.data())); + } + + if (function.isEmpty()) { + result.append(QLatin1Char('?') + library + QLatin1Char('?')); + } else { + result.append(function); + } + } else { + if (numberPrinted == 0) { + // innermost, unknown frames are usually the logging framework itself + continue; + } + result.append(QStringLiteral("???")); + } + numberPrinted++; + } + } + return result; +} + +static QString formatBacktraceForLogMessage(const QMessagePattern::BacktraceParams backtraceParams, + const char *function) +{ + QString backtraceSeparator = backtraceParams.backtraceSeparator; + int backtraceDepth = backtraceParams.backtraceDepth; + + QStringList frames = backtraceFramesForLogMessage(backtraceDepth); + if (frames.isEmpty()) + return QString(); + + // if the first frame is unknown, replace it with the context function + if (function && frames.at(0).startsWith(QLatin1Char('?'))) + frames[0] = QString::fromUtf8(qCleanupFuncinfo(function)); + + return frames.join(backtraceSeparator); +} +#endif // QLOGGING_HAVE_BACKTRACE && !QT_BOOTSTRAPPED + #if defined(QT_USE_SLOG2) #ifndef QT_LOG_CODE #define QT_LOG_CODE 9000 @@ -1336,62 +1420,8 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con #ifdef QLOGGING_HAVE_BACKTRACE } else if (token == backtraceTokenC) { QMessagePattern::BacktraceParams backtraceParams = pattern->backtraceArgs.at(backtraceArgsIdx); - QString backtraceSeparator = backtraceParams.backtraceSeparator; - int backtraceDepth = backtraceParams.backtraceDepth; backtraceArgsIdx++; - QVarLengthArray buffer(7 + backtraceDepth); - int n = backtrace(buffer.data(), buffer.size()); - if (n > 0) { - int numberPrinted = 0; - for (int i = 0; i < n && numberPrinted < backtraceDepth; ++i) { - QScopedPointer strings(backtrace_symbols(buffer.data() + i, 1)); - QString trace = QString::fromLatin1(strings.data()[0]); - // The results of backtrace_symbols looks like this: - // /lib/libc.so.6(__libc_start_main+0xf3) [0x4a937413] - // The offset and function name are optional. - // This regexp tries to extract the librry name (without the path) and the function name. - // This code is protected by QMessagePattern::mutex so it is thread safe on all compilers - static QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"), - QRegularExpression::OptimizeOnFirstUsageOption); - - QRegularExpressionMatch m = rx.match(trace); - if (m.hasMatch()) { - // skip the trace from QtCore that are because of the qDebug itself - QString library = m.captured(1); - QString function = m.captured(2); - if (!numberPrinted && library.contains(QLatin1String("Qt5Core")) - && (function.isEmpty() || function.contains(QLatin1String("Message"), Qt::CaseInsensitive) - || function.contains(QLatin1String("QDebug")))) { - continue; - } - - if (function.startsWith(QLatin1String("_Z"))) { - QScopedPointer demangled( - abi::__cxa_demangle(function.toUtf8(), 0, 0, 0)); - if (demangled) - function = QString::fromUtf8(qCleanupFuncinfo(demangled.data())); - } - - if (numberPrinted > 0) - message.append(backtraceSeparator); - - if (function.isEmpty()) { - if (numberPrinted == 0 && context.function) - message += QString::fromUtf8(qCleanupFuncinfo(context.function)); - else - message += QLatin1Char('?') + library + QLatin1Char('?'); - } else { - message += function; - } - - } else { - if (numberPrinted == 0) - continue; - message += backtraceSeparator + QLatin1String("???"); - } - numberPrinted++; - } - } + message.append(formatBacktraceForLogMessage(backtraceParams, context.function)); #endif } else if (token == timeTokenC) { QString timeFormat = pattern->timeArgs.at(timeArgsIdx); -- cgit v1.2.3 From 28fab275033a6b4f8d6e78da0f729837144b0420 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Apr 2016 15:30:26 +0200 Subject: add AA_CompressHighFrequencyEvents to control compression on xcb 7edd10e6c added this compression feature, but some applications may need to disable it. [ChangeLog][X11] It's now possible to unset AA_CompressHighFrequencyEvents to disable the new X event compression feature that was added in 5.6.0. This is a replacement for the WA_NoX11EventCompression flag in Qt 4. Task-number: QTBUG-44964 Change-Id: I37a9c8a4831f1c02eda0f03b54125f3255d25500 Reviewed-by: Gatis Paeglis --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index c73ceb9503..2a0b8461cd 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -508,6 +508,7 @@ public: AA_UseStyleSheetPropagationInWidgetStyles = 22, // ### Qt 6: remove me AA_DontUseNativeDialogs = 23, AA_SynthesizeMouseForUnhandledTabletEvents = 24, + AA_CompressHighFrequencyEvents = 25, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 60ce1fc916..3c53a23896 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -239,6 +239,17 @@ to mouse events instead. This attribute is enabled by default. This value has been added in Qt 5.7. + \value AA_CompressHighFrequencyEvents Enables compression of certain frequent events. + On the X11 windowing system, the default value is true, which means that + QEvent::MouseMove, QEvent::TouchUpdate, and changes in window size and + position will be combined whenever they occur more frequently than the + application handles them, so that they don't accumulate and overwhelm the + application later. On other platforms, the default is false. + (In the future, the compression feature may be implemented across platforms.) + You can test the attribute to see whether compression is enabled. + If your application needs to handle all events with no compression, + you can unset this attribute. This value has been added in Qt 5.7. + The following values are obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully -- cgit v1.2.3 From 45eba73492c89157b8c353548a948d538748cd43 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 16 May 2016 14:22:03 +0200 Subject: Fix QVariant conversion to an enum type. QVariant::canConvert was returning true for everything can can be converted to integer, but not for integer itself. That's because in QVariant::canConvert we set the targetType to Int of it's an enum, but the Int->Int case was not on the conversion matrix. So this commits adds it to the conversion matrix and now QVariant::canConvert returns consistently true for int itself. But even tough canConvert returned true, it did not actualy do any conversion to the enum type itself. Fix that by handling the case properlt in 'convert' [ChangeLog][QtCore][QVariant] Fixed QVariant::canConvert and conversion from integer types to enumeration types. Task-number: QTBUG-53384 Change-Id: I6ac066f3900e31bfcea7af77836ddfc7730bd60b Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 9298093f44..7596699843 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -945,6 +945,26 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } } #endif + if (QMetaType::typeFlags(t) & QMetaType::IsEnumeration) { + qlonglong value = qConvertToNumber(d, ok); + if (*ok) { + switch (QMetaType::sizeOf(t)) { + case 1: + *static_cast(result) = value; + return true; + case 2: + *static_cast(result) = value; + return true; + case 4: + *static_cast(result) = value; + return true; + case 8: + *static_cast(result) = value; + return true; + } + } + return *ok; + } return false; } return true; @@ -2819,7 +2839,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, + | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int, /*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong -- cgit v1.2.3 From bfa53e1c67eddb14887cda37d7c89c76f4cce378 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Tue, 10 May 2016 16:34:37 +0200 Subject: Compile fix: remove _POSIX_C_SOURCE usage Remove _POSIX_C_SOURCE usage as the reason why it was added is not clear anymore and it causes compile errors on BSD systems if not circumvented by adding further defines to re-enable function calls hidden by the _POSIX_C_SOURCE define. (__BSD_VISIBLE on FreeBSD/OpenBSD and _NETBSD_SOURCE on NetBSD) Change-Id: Ic6b49ddcd6c481b0f2acd598cea5470604e00507 Reviewed-by: Thiago Macieira --- src/corelib/tools/qelapsedtimer_unix.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index c3c930b82e..27f07d094c 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -31,9 +31,6 @@ ** ****************************************************************************/ -// ask for the latest POSIX, just in case -#define _POSIX_C_SOURCE 200809L - #include "qelapsedtimer.h" #if defined(Q_OS_VXWORKS) #include "qfunctions_vxworks.h" -- cgit v1.2.3 From 20211c4213c0b2565ff9ab86b281d069325c1a33 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 19 May 2016 15:56:49 +0200 Subject: Avoid failing on 64-bit ARM Affects systems like the NVIDIA DRIVE CX. This did not show up so far because there was no error when Q_PROCESSOR_ARM was not set. Task-number: QTBUG-53493 Change-Id: I107155b6dc1a881eca6f57374ad8db4458875243 Reviewed-by: Dominik Holland Reviewed-by: Thiago Macieira --- src/corelib/global/qprocessordetection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index ee94720e7a..6ecd41bc30 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -107,7 +107,7 @@ # define Q_PROCESSOR_ARM __TARGET_ARCH_ARM # elif defined(_M_ARM) && _M_ARM > 1 # define Q_PROCESSOR_ARM _M_ARM -# elif defined(__ARM64_ARCH_8__) +# elif defined(__ARM64_ARCH_8__) || defined(__aarch64__) # define Q_PROCESSOR_ARM 8 # elif defined(__ARM_ARCH_7__) \ || defined(__ARM_ARCH_7A__) \ -- cgit v1.2.3