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 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib/global') 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 -- 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/global') 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 dc40abe925db4a6d4f4236f61bb0c55b585c75da Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 17 Aug 2014 13:05:59 -0700 Subject: Move out the code to extract the backtrace to another function This will make it easier to use create backtraces in other contexts. Change-Id: I56b838ab04d9810108fcdb7f8c2fd91255864850 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qlogging.cpp | 140 ++++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 55 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 4851d1ce6f..f2e293c45b 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -54,6 +54,7 @@ #include "qthread.h" #include "private/qloggingregistry_p.h" #include "private/qcoreapplication_p.h" +#include "private/qsimd_p.h" #endif #ifdef Q_OS_WIN #include @@ -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/global') 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 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/global') 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