From b92267cd4c4a7c88aab950ad519943d85add1da2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 6 May 2017 10:49:12 +0200 Subject: [PATCH 01/12] Remove some more register keywords They're deprecated since C++11 and removed in C++17. Change-Id: Ia2acd9312707bfee96838743645a04ae1780e5dd Reviewed-by: Thiago Macieira --- examples/widgets/graphicsview/boxes/3rdparty/fbm.c | 2 +- src/corelib/kernel/qeventdispatcher_win.cpp | 4 ++-- tests/auto/dbus/qdbusmarshall/common.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/widgets/graphicsview/boxes/3rdparty/fbm.c b/examples/widgets/graphicsview/boxes/3rdparty/fbm.c index 98eb87a33b..3eebaabfba 100644 --- a/examples/widgets/graphicsview/boxes/3rdparty/fbm.c +++ b/examples/widgets/graphicsview/boxes/3rdparty/fbm.c @@ -106,7 +106,7 @@ float noise3(float vec[3]) { int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11; float rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v; - register int i, j; + int i, j; if (start) { start = 0; diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 40db5020ab..0952464f53 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -860,7 +860,7 @@ bool QEventDispatcherWin32::unregisterTimers(QObject *object) Q_D(QEventDispatcherWin32); if (d->timerVec.isEmpty()) return false; - register WinTimerInfo *t; + WinTimerInfo *t; for (int i=0; itimerVec.size(); i++) { t = d->timerVec.at(i); if (t && t->obj == object) { // object found @@ -957,7 +957,7 @@ int QEventDispatcherWin32::remainingTime(int timerId) quint64 currentTime = qt_msectime(); - register WinTimerInfo *t; + WinTimerInfo *t; for (int i=0; itimerVec.size(); i++) { t = d->timerVec.at(i); if (t && t->timerId == timerId) { // timer found diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h index f37ba47508..44346cd6f2 100644 --- a/tests/auto/dbus/qdbusmarshall/common.h +++ b/tests/auto/dbus/qdbusmarshall/common.h @@ -437,7 +437,7 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2) case QVariant::DateTime: return compare(arg, v2); default: - register int id = v2.userType(); + int id = v2.userType(); if (id == qMetaTypeId()) return compare(arg, v2); else if (id == qMetaTypeId()) From 225a35a2ab3eeecab693ee83a2b856f2dabe9092 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 5 May 2017 10:20:47 -0700 Subject: [PATCH 02/12] Use QNetworkReply::ProtocolFailure in HTTP/2 failures ProtocolInvalidOperationError are meant for actual replies from the server indicating that the operation is not valid (HTTP 400 Bad Request). Change-Id: I9ad33fff8b634979bdbafffd14bbc57e4b21d6bf Reviewed-by: Timur Pocheptsov --- src/network/access/qhttp2protocolhandler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 555f1ba0ef..44ab637da8 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -528,7 +528,7 @@ void QHttp2ProtocolHandler::handleDATA() auto &stream = activeStreams[streamID]; if (qint32(inboundFrame.payloadSize()) > stream.recvWindow) { - finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError, + finishStreamWithError(stream, QNetworkReply::ProtocolFailure, QLatin1String("flow control error")); sendRST_STREAM(streamID, FLOW_CONTROL_ERROR); markAsReset(streamID); @@ -834,7 +834,7 @@ void QHttp2ProtocolHandler::handleWINDOW_UPDATE() } auto &stream = activeStreams[streamID]; if (!valid || sum_will_overflow(stream.sendWindow, delta)) { - finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError, + finishStreamWithError(stream, QNetworkReply::ProtocolFailure, QLatin1String("invalid WINDOW_UPDATE delta")); sendRST_STREAM(streamID, PROTOCOL_ERROR); markAsReset(streamID); @@ -888,7 +888,7 @@ void QHttp2ProtocolHandler::handleContinuedHEADERS() // We can receive HEADERS on streams initiated by our requests // (these streams are in halfClosedLocal state) or remote-reserved // streams from a server's PUSH_PROMISE. - finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError, + finishStreamWithError(stream, QNetworkReply::ProtocolFailure, QLatin1String("HEADERS on invalid stream")); sendRST_STREAM(streamID, CANCEL); markAsReset(streamID); @@ -977,7 +977,7 @@ bool QHttp2ProtocolHandler::acceptSetting(Http2::Settings identifier, quint32 ne for (auto id : brokenStreams) { auto &stream = activeStreams[id]; - finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError, + finishStreamWithError(stream, QNetworkReply::ProtocolFailure, QLatin1String("SETTINGS window overflow")); sendRST_STREAM(id, PROTOCOL_ERROR); markAsReset(id); From 77d82107b74ae8b3a1851250343eea3c0809f3c3 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 8 May 2017 10:20:08 +0200 Subject: [PATCH 03/12] winrt: Do not add windeployqt dependency for static builds in VS Change-Id: Iec6ebbfd73741d511008633b5fe0d9975e975729 Reviewed-by: Maurice Kalinowski --- mkspecs/features/winrt/default_pre.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/winrt/default_pre.prf b/mkspecs/features/winrt/default_pre.prf index 8b9c1d7663..966d24f091 100644 --- a/mkspecs/features/winrt/default_pre.prf +++ b/mkspecs/features/winrt/default_pre.prf @@ -9,6 +9,6 @@ CONFIG(debug, debug|release): \ else: \ QMAKE_LIBS = ucrt.lib vcruntime.lib $$QMAKE_LIBS -equals(TEMPLATE, "vcapp"): CONFIG += windeployqt +equals(TEMPLATE, "vcapp"):!static: CONFIG += windeployqt load(default_pre) From be36fca32be499db45fe86aed520124b36863d65 Mon Sep 17 00:00:00 2001 From: Sami Nurmenniemi Date: Mon, 24 Apr 2017 15:19:56 +0300 Subject: [PATCH 04/12] tst_qmessagehandler: fix qMessagePattern for arm with optimizations on Backtrace logging tests were not passing for arm when -O2 option was used. Set "-fno-inline" on for the app whose backtrace is to be inspected. Task-number: QTBUG-59966 Change-Id: Id1bbf78c31dc524357a30c7d39c239689621b155 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/global/qlogging/app/app.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/global/qlogging/app/app.pro b/tests/auto/corelib/global/qlogging/app/app.pro index 6fba1b6129..30751d89ec 100644 --- a/tests/auto/corelib/global/qlogging/app/app.pro +++ b/tests/auto/corelib/global/qlogging/app/app.pro @@ -13,5 +13,5 @@ DEFINES += QT_MESSAGELOGCONTEXT gcc:!mingw:!haiku { QMAKE_LFLAGS += -rdynamic - contains(QT_ARCH, arm): QMAKE_CXXFLAGS += -funwind-tables + contains(QT_ARCH, arm): QMAKE_CXXFLAGS += -funwind-tables -fno-inline } From f12e4903c7b7c06ad3068e4ac195ff0bbe857e28 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Thu, 4 May 2017 19:36:34 +0200 Subject: [PATCH 05/12] Warn if files are not found because of features.filesystemiterator Change-Id: Ife3197aa1c56ba3ab6e7f530fbcbcf761f223b16 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/corelib/io/qdiriterator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 5fd9edc552..b1d920c6ee 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -204,6 +204,8 @@ void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo) QFileSystemIterator *it = new QFileSystemIterator(fileInfo.d_ptr->fileEntry, filters, nameFilters, iteratorFlags); nativeIterators << it; +#else + qWarning("Qt was built with -no-feature-filesystemiterator: no files/plugins will be found!"); #endif } } From 961fe0df2e25225049bcfd8d6d2f9e314dc829a6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 5 May 2017 15:48:26 +0200 Subject: [PATCH 06/12] make configure -list-features print the section field prefix it to the purpose field. this makes the presentation more consistent with the graphical tool, and avoids the need to be redundant in the description. Change-Id: Iea58885637e0518aa1ec2f69ff05090b7e1e77a9 Reviewed-by: Stephan Binner Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 966c43108c..5cbc0d4bfd 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1919,8 +1919,10 @@ qtConfCheckErrors() for (k, $${currentConfig}.features._KEYS_) { pp = $$eval($${currentConfig}.features.$${k}.purpose) !isEmpty(pp) { + pfx = $$eval($${currentConfig}.features.$${k}.section) + !isEmpty(pfx): pfx = "$$pfx: " all_ft += $$qtConfPadCols($$k, ".......................", \ - $$section(pp, $$escape_expand(\\n), 0, 0)) + $$pfx$$section(pp, $$escape_expand(\\n), 0, 0)) } } } From b7da94ce5251d91acd60d4c82684f12c7d11affc Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 3 May 2017 15:22:23 +0100 Subject: [PATCH 07/12] QObject: turn the narrowing test into static_asserts The conditions checked are compile-time conditions anyhow. Simplify or strenghten a few conditions while at it. Change-Id: If07f2aedca4c3632d852a8fdb2b3f7eb55a96c93 Reviewed-by: Edward Welbourne Reviewed-by: James McDonnell --- .../corelib/kernel/qobject/tst_qobject.cpp | 744 ++++++++---------- 1 file changed, 347 insertions(+), 397 deletions(-) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index db6bdf0809..642d48d721 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -6926,309 +6926,261 @@ void tst_QObject::checkArgumentsForNarrowing() enum UnscopedEnum {}; enum SignedUnscopedEnum { SignedUnscopedEnumV1 = -1, SignedUnscopedEnumV2 = 1 }; - QVERIFY(sizeof(UnscopedEnum) <= sizeof(int)); - QVERIFY(sizeof(SignedUnscopedEnum) <= sizeof(int)); + // a constexpr would suffice, but MSVC2013 RTM doesn't support them... +#define IS_UNSCOPED_ENUM_SIGNED (std::is_signed::type>::value) + +#define NARROWS_IF(x, y, test) Q_STATIC_ASSERT((QtPrivate::AreArgumentsNarrowedBase::value) == (test)) +#define FITS_IF(x, y, test) Q_STATIC_ASSERT((QtPrivate::AreArgumentsNarrowedBase::value) != (test)) +#define NARROWS(x, y) NARROWS_IF(x, y, true) +#define FITS(x, y) FITS_IF(x, y, true) + + Q_STATIC_ASSERT(sizeof(UnscopedEnum) <= sizeof(int)); + Q_STATIC_ASSERT(sizeof(SignedUnscopedEnum) <= sizeof(int)); // floating point to integral - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(float, bool); + NARROWS(double, bool); + NARROWS(long double, bool); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(float, char); + NARROWS(double, char); + NARROWS(long double, char); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(float, short); + NARROWS(double, short); + NARROWS(long double, short); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(float, int); + NARROWS(double, int); + NARROWS(long double, int); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(float, long); + NARROWS(double, long); + NARROWS(long double, long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(float, long long); + NARROWS(double, long long); + NARROWS(long double, long long); // floating point to a smaller floating point - if (sizeof(double) > sizeof(float)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(double, float, (sizeof(double) > sizeof(float))); + NARROWS_IF(long double, float, (sizeof(long double) > sizeof(float))); + FITS(float, double); + FITS(float, long double); - if (sizeof(long double) > sizeof(double)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(long double, double, (sizeof(long double) > sizeof(double))); + FITS(double, long double); // integral to floating point - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(bool, float); + NARROWS(bool, double); + NARROWS(bool, long double); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(char, float); + NARROWS(char, double); + NARROWS(char, long double); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(short, float); + NARROWS(short, double); + NARROWS(short, long double); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(int, float); + NARROWS(int, double); + NARROWS(int, long double); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(long, float); + NARROWS(long, double); + NARROWS(long, long double); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(long long, float); + NARROWS(long long, double); + NARROWS(long long, long double); // enum to floating point - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(UnscopedEnum, float); + NARROWS(UnscopedEnum, double); + NARROWS(UnscopedEnum, long double); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(SignedUnscopedEnum, float); + NARROWS(SignedUnscopedEnum, double); + NARROWS(SignedUnscopedEnum, long double); // integral to smaller integral - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(bool, bool); + FITS(char, char); + FITS(signed char, signed char); + FITS(signed char, short); + FITS(signed char, int); + FITS(signed char, long); + FITS(signed char, long long); + FITS(unsigned char, unsigned char); + FITS(unsigned char, unsigned short); + FITS(unsigned char, unsigned int); + FITS(unsigned char, unsigned long); + FITS(unsigned char, unsigned long long); - if (sizeof(bool) > sizeof(char)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(bool, unsigned char, (sizeof(bool) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(bool, unsigned short, (sizeof(bool) > sizeof(short) || std::is_signed::value)); + NARROWS_IF(bool, unsigned int, (sizeof(bool) > sizeof(int) || std::is_signed::value)); + NARROWS_IF(bool, unsigned long, (sizeof(bool) > sizeof(long) || std::is_signed::value)); + NARROWS_IF(bool, unsigned long long, (sizeof(bool) > sizeof(long long) || std::is_signed::value)); - if (sizeof(bool) > sizeof(short)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(short, char, (sizeof(short) > sizeof(char) || std::is_unsigned::value)); + NARROWS_IF(short, unsigned char, (sizeof(short) > sizeof(char))); + NARROWS_IF(short, signed char, (sizeof(short) > sizeof(char))); - if (sizeof(bool) > sizeof(int)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(unsigned short, char, (sizeof(short) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(unsigned short, unsigned char, (sizeof(short) > sizeof(char))); + NARROWS_IF(unsigned short, signed char, (sizeof(short) > sizeof(char))); - if (sizeof(bool) > sizeof(long)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(short, short); + FITS(short, int); + FITS(short, long); + FITS(short, long long); - if (sizeof(bool) > sizeof(long long)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(unsigned short, unsigned short); + FITS(unsigned short, unsigned int); + FITS(unsigned short, unsigned long); + FITS(unsigned short, unsigned long long); - if (sizeof(short) > sizeof(char)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(int, char, (sizeof(int) > sizeof(char) || std::is_unsigned::value)); + NARROWS(int, unsigned char); + NARROWS_IF(int, signed char, (sizeof(int) > sizeof(char))); + NARROWS_IF(int, short, (sizeof(int) > sizeof(short))); + NARROWS(int, unsigned short); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } + NARROWS_IF(unsigned int, char, (sizeof(int) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(unsigned int, unsigned char, (sizeof(int) > sizeof(char))); + NARROWS(unsigned int, signed char); + NARROWS(unsigned int, short); + NARROWS_IF(unsigned int, unsigned short, (sizeof(int) > sizeof(short))); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(int, int); + FITS(int, long); + FITS(int, long long); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(unsigned int, unsigned int); + FITS(unsigned int, unsigned long); + FITS(unsigned int, unsigned long long); - if (sizeof(int) > sizeof(short)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(long, char, (sizeof(long) > sizeof(char) || std::is_unsigned::value)); + NARROWS(long, unsigned char); + NARROWS_IF(long, signed char, (sizeof(long) > sizeof(char))); + NARROWS_IF(long, short, (sizeof(long) > sizeof(short))); + NARROWS(long, unsigned short); + NARROWS_IF(long, int, (sizeof(long) > sizeof(int))); + NARROWS(long, unsigned int); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } + NARROWS_IF(unsigned long, char, (sizeof(long) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(unsigned long, unsigned char, (sizeof(long) > sizeof(char))); + NARROWS(unsigned long, signed char); + NARROWS(unsigned long, short); + NARROWS_IF(unsigned long, unsigned short, (sizeof(long) > sizeof(short))); + NARROWS(unsigned long, int); + NARROWS_IF(unsigned long, unsigned int, (sizeof(long) > sizeof(int))); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(long, long); + FITS(long, long long); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(unsigned long, unsigned long); + FITS(unsigned long, unsigned long long); - if (sizeof(long) > sizeof(int)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(long long, char, (sizeof(long long) > sizeof(char) || std::is_unsigned::value)); + NARROWS(long long, unsigned char); + NARROWS_IF(long long, signed char, (sizeof(long long) > sizeof(char))); + NARROWS_IF(long long, short, (sizeof(long long) > sizeof(short))); + NARROWS(long long, unsigned short); + NARROWS_IF(long long, int, (sizeof(long long) > sizeof(int))); + NARROWS(long long, unsigned int); + NARROWS_IF(long long, long, (sizeof(long long) > sizeof(long))); + NARROWS(long long, unsigned long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } + NARROWS_IF(unsigned long long, char, (sizeof(long long) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(unsigned long long, unsigned char, (sizeof(long long) > sizeof(char))); + NARROWS(unsigned long long, signed char); + NARROWS(unsigned long long, short); + NARROWS_IF(unsigned long long, unsigned short, (sizeof(long long) > sizeof(short))); + NARROWS(unsigned long long, int); + NARROWS_IF(unsigned long long, unsigned int, (sizeof(long long) > sizeof(int))); + NARROWS(unsigned long long, long); + NARROWS_IF(unsigned long long, unsigned long, (sizeof(long long) > sizeof(long))); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - - if (sizeof(long long) > sizeof(long)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } - - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(long long, long long); + FITS(unsigned long long, unsigned long long); // integral to integral with different signedness. smaller ones tested above - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(signed char, unsigned char); + NARROWS(signed char, unsigned short); + NARROWS(signed char, unsigned int); + NARROWS(signed char, unsigned long); + NARROWS(signed char, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(unsigned char, signed char); + FITS(unsigned char, short); + FITS(unsigned char, int); + FITS(unsigned char, long); + FITS(unsigned char, long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(short, unsigned short); + NARROWS(short, unsigned int); + NARROWS(short, unsigned long); + NARROWS(short, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(unsigned short, short); + FITS(unsigned short, int); + FITS(unsigned short, long); + FITS(unsigned short, long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(int, unsigned int); + NARROWS(int, unsigned long); + NARROWS(int, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QCOMPARE((QtPrivate::AreArgumentsNarrowedBase::value), sizeof(int) >= sizeof(long)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(unsigned int, int); + NARROWS_IF(unsigned int, long, (sizeof(int) >= sizeof(long))); + FITS(unsigned int, long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(long, unsigned long); + NARROWS(long, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QCOMPARE((QtPrivate::AreArgumentsNarrowedBase::value), sizeof(long) >= sizeof(long long)); + NARROWS(unsigned long, long); + NARROWS_IF(unsigned long, long long, (sizeof(long) >= sizeof(long long))); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(long long, unsigned long long); + NARROWS(unsigned long long, long long); // enum to smaller integral - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + // (note that we know that sizeof(UnscopedEnum) <= sizeof(int) + FITS(UnscopedEnum, UnscopedEnum); + FITS(SignedUnscopedEnum, SignedUnscopedEnum); - if (std::is_signed::type>::value) { - if (sizeof(UnscopedEnum) > sizeof(char)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(UnscopedEnum, char, ((sizeof(UnscopedEnum) > sizeof(char)) || (sizeof(UnscopedEnum) == sizeof(char) && IS_UNSCOPED_ENUM_SIGNED == std::is_signed::value))); + NARROWS_IF(UnscopedEnum, signed char, ((sizeof(UnscopedEnum) > sizeof(char)) || (sizeof(UnscopedEnum) == sizeof(char) && !IS_UNSCOPED_ENUM_SIGNED))); + NARROWS_IF(UnscopedEnum, unsigned char, ((sizeof(UnscopedEnum) > sizeof(char)) || IS_UNSCOPED_ENUM_SIGNED)); - if (sizeof(UnscopedEnum) > sizeof(short)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(UnscopedEnum, short, ((sizeof(UnscopedEnum) > sizeof(short)) || (sizeof(UnscopedEnum) == sizeof(short) && !IS_UNSCOPED_ENUM_SIGNED))); + NARROWS_IF(UnscopedEnum, unsigned short, ((sizeof(UnscopedEnum) > sizeof(short)) || IS_UNSCOPED_ENUM_SIGNED)); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - } else { - if (sizeof(UnscopedEnum) > sizeof(bool)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(UnscopedEnum, int, (sizeof(UnscopedEnum) == sizeof(int) && !IS_UNSCOPED_ENUM_SIGNED)); + NARROWS_IF(UnscopedEnum, unsigned int, IS_UNSCOPED_ENUM_SIGNED); - if (sizeof(UnscopedEnum) > sizeof(char)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(UnscopedEnum, long, (sizeof(UnscopedEnum) == sizeof(long) && !IS_UNSCOPED_ENUM_SIGNED)); + NARROWS_IF(UnscopedEnum, unsigned long, IS_UNSCOPED_ENUM_SIGNED); - if (sizeof(UnscopedEnum) > sizeof(short)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(UnscopedEnum, long long, (sizeof(UnscopedEnum) == sizeof(long long) && !IS_UNSCOPED_ENUM_SIGNED)); + NARROWS_IF(UnscopedEnum, unsigned long long, IS_UNSCOPED_ENUM_SIGNED); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - } + Q_STATIC_ASSERT(std::is_signed::type>::value); - QVERIFY(std::is_signed::type>::value); - - if (sizeof(SignedUnscopedEnum) > sizeof(char)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - - if (sizeof(SignedUnscopedEnum) > sizeof(short)) - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - else - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(SignedUnscopedEnum, signed char, (sizeof(SignedUnscopedEnum) > sizeof(char))); + NARROWS_IF(SignedUnscopedEnum, short, (sizeof(SignedUnscopedEnum) > sizeof(short))); + FITS(SignedUnscopedEnum, int); + FITS(SignedUnscopedEnum, long); + FITS(SignedUnscopedEnum, long long); enum class ScopedEnumBackedBySChar : signed char { A }; @@ -7242,192 +7194,190 @@ void tst_QObject::checkArgumentsForNarrowing() enum class ScopedEnumBackedByLongLong : long long { A }; enum class ScopedEnumBackedByULongLong : unsigned long long { A }; - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(ScopedEnumBackedBySChar, ScopedEnumBackedBySChar); + FITS(ScopedEnumBackedByUChar, ScopedEnumBackedByUChar); + FITS(ScopedEnumBackedByShort, ScopedEnumBackedByShort); + FITS(ScopedEnumBackedByUShort, ScopedEnumBackedByUShort); + FITS(ScopedEnumBackedByInt, ScopedEnumBackedByInt); + FITS(ScopedEnumBackedByUInt, ScopedEnumBackedByUInt); + FITS(ScopedEnumBackedByLong, ScopedEnumBackedByLong); + FITS(ScopedEnumBackedByULong, ScopedEnumBackedByULong); + FITS(ScopedEnumBackedByLongLong, ScopedEnumBackedByLongLong); + FITS(ScopedEnumBackedByULongLong, ScopedEnumBackedByULongLong); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(ScopedEnumBackedBySChar, signed char); + FITS(ScopedEnumBackedByUChar, unsigned char); + FITS(ScopedEnumBackedByShort, short); + FITS(ScopedEnumBackedByUShort, unsigned short); + FITS(ScopedEnumBackedByInt, int); + FITS(ScopedEnumBackedByUInt, unsigned int); + FITS(ScopedEnumBackedByLong, long); + FITS(ScopedEnumBackedByULong, unsigned long); + FITS(ScopedEnumBackedByLongLong, long long); + FITS(ScopedEnumBackedByULongLong, unsigned long long); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(ScopedEnumBackedBySChar, signed char); + FITS(ScopedEnumBackedBySChar, short); + FITS(ScopedEnumBackedBySChar, int); + FITS(ScopedEnumBackedBySChar, long); + FITS(ScopedEnumBackedBySChar, long long); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(ScopedEnumBackedByUChar, unsigned char); + FITS(ScopedEnumBackedByUChar, unsigned short); + FITS(ScopedEnumBackedByUChar, unsigned int); + FITS(ScopedEnumBackedByUChar, unsigned long); + FITS(ScopedEnumBackedByUChar, unsigned long long); - if (sizeof(short) > sizeof(char)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(ScopedEnumBackedByShort, char, (sizeof(short) > sizeof(char) || std::is_unsigned::value)); + NARROWS_IF(ScopedEnumBackedByUShort, char, (sizeof(short) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(ScopedEnumBackedByInt, char, (sizeof(int) > sizeof(char) || std::is_unsigned::value)); + NARROWS_IF(ScopedEnumBackedByUInt, char, (sizeof(int) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(ScopedEnumBackedByLong, char, (sizeof(long) > sizeof(char) || std::is_unsigned::value)); + NARROWS_IF(ScopedEnumBackedByULong, char, (sizeof(long) > sizeof(char) || std::is_signed::value)); + NARROWS_IF(ScopedEnumBackedByLongLong, char, (sizeof(long long) > sizeof(char) || std::is_unsigned::value)); + NARROWS_IF(ScopedEnumBackedByULongLong, char, (sizeof(long long) > sizeof(char) || std::is_signed::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(ScopedEnumBackedByShort, signed char, (sizeof(short) > sizeof(char))); + NARROWS(ScopedEnumBackedByUShort, signed char); + NARROWS_IF(ScopedEnumBackedByInt, signed char, (sizeof(int) > sizeof(char))); + NARROWS(ScopedEnumBackedByUInt, signed char); + NARROWS_IF(ScopedEnumBackedByLong, signed char, (sizeof(long) > sizeof(char))); + NARROWS(ScopedEnumBackedByULong, signed char); + NARROWS_IF(ScopedEnumBackedByLongLong, signed char, (sizeof(long long) > sizeof(char))); + NARROWS(ScopedEnumBackedByULongLong, signed char); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } + NARROWS(ScopedEnumBackedByShort, unsigned char); + NARROWS_IF(ScopedEnumBackedByUShort, unsigned char, (sizeof(short) > sizeof(char))); + NARROWS(ScopedEnumBackedByInt, unsigned char); + NARROWS_IF(ScopedEnumBackedByUInt, unsigned char, (sizeof(int) > sizeof(char))); + NARROWS(ScopedEnumBackedByLong, unsigned char); + NARROWS_IF(ScopedEnumBackedByULong, unsigned char, (sizeof(long) > sizeof(char))); + NARROWS(ScopedEnumBackedByLongLong, unsigned char); + NARROWS_IF(ScopedEnumBackedByULongLong, unsigned char, (sizeof(long long) > sizeof(char))); - if (sizeof(int) > sizeof(short)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(ScopedEnumBackedByInt, short, (sizeof(int) > sizeof(short))); + NARROWS(ScopedEnumBackedByUInt, short); + NARROWS_IF(ScopedEnumBackedByLong, short, (sizeof(long) > sizeof(short))); + NARROWS(ScopedEnumBackedByULong, short); + NARROWS_IF(ScopedEnumBackedByLongLong, short, (sizeof(long long) > sizeof(short))); + NARROWS(ScopedEnumBackedByULongLong, short); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } + NARROWS(ScopedEnumBackedByInt, unsigned short); + NARROWS_IF(ScopedEnumBackedByUInt, unsigned short, (sizeof(int) > sizeof(short))); + NARROWS(ScopedEnumBackedByLong, unsigned short); + NARROWS_IF(ScopedEnumBackedByULong, unsigned short, (sizeof(long) > sizeof(short))); + NARROWS(ScopedEnumBackedByLongLong, unsigned short); + NARROWS_IF(ScopedEnumBackedByULongLong, unsigned short, (sizeof(long long) > sizeof(short))); - if (sizeof(long) > sizeof(int)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(ScopedEnumBackedByLong, int, (sizeof(long) > sizeof(int))); + NARROWS(ScopedEnumBackedByULong, int); + NARROWS_IF(ScopedEnumBackedByLongLong, int, (sizeof(long long) > sizeof(int))); + NARROWS(ScopedEnumBackedByULongLong, int); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } + NARROWS(ScopedEnumBackedByLong, unsigned int); + NARROWS_IF(ScopedEnumBackedByULong, unsigned int, (sizeof(long) > sizeof(int))); + NARROWS(ScopedEnumBackedByLongLong, unsigned int); + NARROWS_IF(ScopedEnumBackedByULongLong, unsigned int, (sizeof(long long) > sizeof(int))); - if (sizeof(long long) > sizeof(long)) { - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS_IF(ScopedEnumBackedByLongLong, long, (sizeof(long long) > sizeof(long))); + NARROWS(ScopedEnumBackedByULongLong, long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - } + NARROWS(ScopedEnumBackedByLongLong, unsigned long); + NARROWS_IF(ScopedEnumBackedByULongLong, unsigned long, (sizeof(long long) > sizeof(long))); // different signedness of the underlying type - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(SignedUnscopedEnum, unsigned char); + NARROWS(SignedUnscopedEnum, unsigned short); + NARROWS(SignedUnscopedEnum, unsigned int); + NARROWS(SignedUnscopedEnum, unsigned long); + NARROWS(SignedUnscopedEnum, unsigned long long); + NARROWS(ScopedEnumBackedBySChar, unsigned char); + NARROWS(ScopedEnumBackedBySChar, unsigned short); + NARROWS(ScopedEnumBackedBySChar, unsigned int); + NARROWS(ScopedEnumBackedBySChar, unsigned long); + NARROWS(ScopedEnumBackedBySChar, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByShort, unsigned char); + NARROWS(ScopedEnumBackedByShort, unsigned short); + NARROWS(ScopedEnumBackedByShort, unsigned int); + NARROWS(ScopedEnumBackedByShort, unsigned long); + NARROWS(ScopedEnumBackedByShort, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByInt, unsigned char); + NARROWS(ScopedEnumBackedByInt, unsigned short); + NARROWS(ScopedEnumBackedByInt, unsigned int); + NARROWS(ScopedEnumBackedByInt, unsigned long); + NARROWS(ScopedEnumBackedByInt, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByLong, unsigned char); + NARROWS(ScopedEnumBackedByLong, unsigned short); + NARROWS(ScopedEnumBackedByLong, unsigned int); + NARROWS(ScopedEnumBackedByLong, unsigned long); + NARROWS(ScopedEnumBackedByLong, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByLongLong, unsigned char); + NARROWS(ScopedEnumBackedByLongLong, unsigned short); + NARROWS(ScopedEnumBackedByLongLong, unsigned int); + NARROWS(ScopedEnumBackedByLongLong, unsigned long); + NARROWS(ScopedEnumBackedByLongLong, unsigned long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByUChar, signed char); + FITS_IF(ScopedEnumBackedByUChar, short, (sizeof(char) < sizeof(short))); + FITS_IF(ScopedEnumBackedByUChar, int, (sizeof(char) < sizeof(int))); + FITS_IF(ScopedEnumBackedByUChar, long, (sizeof(char) < sizeof(long))); + FITS_IF(ScopedEnumBackedByUChar, long long, (sizeof(char) < sizeof(long long))); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByUShort, signed char); + NARROWS(ScopedEnumBackedByUShort, short); + FITS_IF(ScopedEnumBackedByUShort, int, (sizeof(short) < sizeof(int))); + FITS_IF(ScopedEnumBackedByUShort, long, (sizeof(short) < sizeof(long))); + FITS_IF(ScopedEnumBackedByUShort, long long, (sizeof(short) < sizeof(long long))); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByUInt, signed char); + NARROWS(ScopedEnumBackedByUInt, short); + NARROWS(ScopedEnumBackedByUInt, int); + FITS_IF(ScopedEnumBackedByUInt, long, (sizeof(ScopedEnumBackedByUInt) < sizeof(long))); + FITS(ScopedEnumBackedByUInt, long long); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QCOMPARE((QtPrivate::AreArgumentsNarrowedBase::value), sizeof(ScopedEnumBackedByUInt) >= sizeof(long)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByULong, signed char); + NARROWS(ScopedEnumBackedByULong, short); + NARROWS(ScopedEnumBackedByULong, int); + NARROWS(ScopedEnumBackedByULong, long); + FITS_IF(ScopedEnumBackedByULong, long long, (sizeof(ScopedEnumBackedByULong) < sizeof(long long))); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QCOMPARE((QtPrivate::AreArgumentsNarrowedBase::value), sizeof(ScopedEnumBackedByULong) >= sizeof(long long)); - - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((QtPrivate::AreArgumentsNarrowedBase::value)); + NARROWS(ScopedEnumBackedByULongLong, signed char); + NARROWS(ScopedEnumBackedByULongLong, short); + NARROWS(ScopedEnumBackedByULongLong, int); + NARROWS(ScopedEnumBackedByULongLong, long); + NARROWS(ScopedEnumBackedByULongLong, long long); // other types which should be always unaffected - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(void *, void *); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(QString, QString); + FITS(QString &, QString &); + FITS(const QString &, const QString &); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(QObject, QObject); + FITS(QObject *, QObject *); + FITS(const QObject *, const QObject *); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(std::nullptr_t, std::nullptr_t); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); - QVERIFY((!QtPrivate::AreArgumentsNarrowedBase::value)); + FITS(QString, QObject); + FITS(QString, QVariant); + FITS(QString, void *); + FITS(QString, long long); + FITS(bool, const QObject *&); + FITS(int (*)(bool), void (QObject::*)()); + +#undef IS_UNSCOPED_ENUM_SIGNED + +#undef NARROWS_IF +#undef FITS_IF +#undef NARROWS +#undef FITS } // Test for QtPrivate::HasQ_OBJECT_Macro From b97a70361308b10431222a0e95f3befa15fdcc71 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 May 2017 13:54:43 +0200 Subject: [PATCH 08/12] Windows QPA: Call InvalidateRect() for GL windows when Aero is off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some AMD cards have been reported to not update otherwise. Task-number: QTBUG-60527 Change-Id: I84d57a57eb2b76fb31255ae42b79b96ab7b257c9 Reviewed-by: Kimmo Leppälä Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowswindow.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 2875463e62..d4effde52d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1616,6 +1616,16 @@ static inline bool dwmIsCompositionEnabled() return SUCCEEDED(DwmIsCompositionEnabled(&dWmCompositionEnabled)) && dWmCompositionEnabled == TRUE; } +static inline bool isSoftwareGl() +{ +#if QT_CONFIG(dynamicgl) + return QOpenGLStaticContext::opengl32.moduleIsNotOpengl32() + && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL; +#else + return false; +#endif // dynamicgl +} + bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, WPARAM, LPARAM) { @@ -1627,15 +1637,10 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, return false; PAINTSTRUCT ps; -#if QT_CONFIG(dynamicgl) - // QTBUG-58178: GL software rendering needs InvalidateRect() to suppress - // artifacts while resizing. - if (testFlag(OpenGLSurface) - && QOpenGLStaticContext::opengl32.moduleIsNotOpengl32() - && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + // GL software rendering (QTBUG-58178) and Windows 7/Aero off with some AMD cards + // (QTBUG-60527) need InvalidateRect() to suppress artifacts while resizing. + if (testFlag(OpenGLSurface) && (isSoftwareGl() || !dwmIsCompositionEnabled())) InvalidateRect(hwnd, 0, false); - } -#endif // dynamicgl BeginPaint(hwnd, &ps); From ce3a77eed580cdd4e2367216b3b5ede50c4be516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 20 Apr 2017 18:24:12 +0200 Subject: [PATCH 09/12] macOS: Add a few more platform window checks in QNSView And unify all of them to use regular pointer check syntax, to stay consistent with other uses of non-smart pointers. Change-Id: Ic55d7a16f2010120aaa8eac5b2df8189490671a2 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qnsview.mm | 60 ++++++++++++++------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 6494dd3386..72e90a5363 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -237,7 +237,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)viewDidMoveToSuperview { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if (!(m_platformWindow->m_viewIsToBeEmbedded)) @@ -260,7 +260,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (QWindow *)topLevelWindow { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return nullptr; QWindow *focusWindow = m_platformWindow->window(); @@ -278,7 +278,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)updateGeometry { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; QRect geometry; @@ -437,8 +437,11 @@ static bool _q_dontOverrideCtrlLMB = false; } } -- (void) drawRect:(NSRect)dirtyRect +- (void)drawRect:(NSRect)dirtyRect { + if (!m_platformWindow) + return; + qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_platformWindow->window() << QRectF::fromCGRect(NSRectToCGRect(dirtyRect)); #ifndef QT_NO_OPENGL @@ -627,7 +630,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)handleMouseEvent:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; // Tablet events may come in via the mouse event handlers, @@ -644,7 +647,7 @@ static bool _q_dontOverrideCtrlLMB = false; else m_platformWindow->m_forwardWindow.clear(); } - if (targetView->m_platformWindow.isNull()) + if (!targetView.platformWindow) return; // Popups implicitly grap mouse events; forward to the active popup if there is one @@ -670,7 +673,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; // get m_buttons in sync @@ -955,7 +958,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseMovedImpl:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self isTransparentForUserInput]) @@ -989,7 +992,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseEnteredImpl:(NSEvent *)theEvent { Q_UNUSED(theEvent) - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; m_platformWindow->m_windowUnderMouse = true; @@ -1011,7 +1014,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseExitedImpl:(NSEvent *)theEvent { Q_UNUSED(theEvent); - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; m_platformWindow->m_windowUnderMouse = false; @@ -1040,7 +1043,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) - (bool)handleTabletEvent: (NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return false; NSEventType eventType = [theEvent type]; @@ -1200,7 +1203,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (bool)shouldSendSingleTouch { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return true; // QtWidgets expects single-point touch events, QtDeclarative does not. @@ -1210,7 +1213,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesBeganWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1221,7 +1224,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesMovedWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1232,7 +1235,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesEndedWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1243,7 +1246,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesCancelledWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1273,7 +1276,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } - (void)magnifyWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self handleGestureAsBeginEnd:event]) @@ -1290,7 +1293,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)smartMagnifyWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; static bool zoomIn = true; @@ -1306,7 +1309,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)rotateWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self handleGestureAsBeginEnd:event]) @@ -1322,7 +1325,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)swipeWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY]; @@ -1347,7 +1350,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)beginGestureWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1361,7 +1364,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)endGestureWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; qCDebug(lcQpaGestures) << "endGestureWithEvent"; @@ -1377,7 +1380,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) #ifndef QT_NO_WHEELEVENT - (void)scrollWheel:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self isTransparentForUserInput]) @@ -1879,6 +1882,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (NSArray*)validAttributesForMarkedText { + if (!m_platformWindow) + return nil; + if (m_platformWindow->window() != QGuiApplication::focusWindow()) return nil; @@ -2050,7 +2056,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // Sends drag update to Qt, return the action - (NSDragOperation)handleDrag:(id )sender { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return NSDragOperationNone; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; @@ -2080,7 +2086,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (void)draggingExited:(id )sender { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; QWindow *target = findEventTargetWindow(m_platformWindow->window()); @@ -2097,7 +2103,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // called on drop, send the drop to Qt and return if it was accepted. - (BOOL)performDragOperation:(id )sender { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return false; QWindow *target = findEventTargetWindow(m_platformWindow->window()); @@ -2131,7 +2137,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin Q_UNUSED(session); Q_UNUSED(operation); - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; QWindow *target = findEventTargetWindow(m_platformWindow->window()); From 16f950c702646b0f07c8c0a473759c20a6313fb2 Mon Sep 17 00:00:00 2001 From: Teemu Holappa Date: Fri, 20 Jan 2017 13:28:42 +0200 Subject: [PATCH 10/12] Skip failing autotests with b2qt toolchain Task-number: QTBUG-59966 Change-Id: I36d114107187db22841ebfeff8fa8175daff6d03 Reviewed-by: Thiago Macieira Reviewed-by: Simon Hausmann --- .../gui/kernel/qinputmethod/tst_qinputmethod.cpp | 5 +++++ tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 15 +++++++++++---- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 4 ++++ .../qgraphicsview/tst_qgraphicsview.cpp | 6 +++++- .../widgets/widgets/qmenubar/tst_qmenubar.cpp | 11 +++++++++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index d024538ee0..509f8bd45f 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -287,6 +287,11 @@ void tst_qinputmethod::inputMethodAccepted() if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive) + || !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) { + QSKIP("minimal/offscreen: This fails. Figure out why."); + } + if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive)) QSKIP("XCB: depends on dedicated platform context."); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 0196c7d72c..4cccf08086 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -1829,6 +1829,12 @@ void tst_QWindow::initialSize() } } +static bool isPlatformOffscreenOrMinimal() +{ + return ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))); +} + void tst_QWindow::modalDialog() { if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -1853,8 +1859,7 @@ void tst_QWindow::modalDialog() QGuiApplication::sync(); QGuiApplication::processEvents(); - if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive) - || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) { + if (isPlatformOffscreenOrMinimal()) { QWARN("Focus stays in normalWindow on offscreen/minimal platforms"); QTRY_COMPARE(QGuiApplication::focusWindow(), &normalWindow); return; @@ -1899,8 +1904,7 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal() QGuiApplication::sync(); QGuiApplication::processEvents(); - if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive) - || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) { + if (isPlatformOffscreenOrMinimal()) { QWARN("Focus is lost when closing modal dialog on offscreen/minimal platforms"); QTRY_COMPARE(QGuiApplication::focusWindow(), nullptr); return; @@ -1994,6 +1998,9 @@ void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109() if (QGuiApplication::platformName() == QLatin1String("cocoa")) QSKIP("This test fails on OS X on CI"); + if (isPlatformOffscreenOrMinimal()) + QSKIP("Can't test window focusing on offscreen/minimal"); + const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center(); const int childOffset = 16; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 3562bc63f4..8db4489ec1 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -3004,6 +3004,10 @@ void fpe_steepSlopes() void fpe_radialGradients() { +#if defined(Q_PROCESSOR_ARM) + QEXPECT_FAIL("", "Test fails for ARM (QTBUG-59961)", Continue); +#endif + FpExceptionChecker checker(FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO); QImage img(21, 21, QImage::Format_ARGB32_Premultiplied); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 76b25cdb52..1a96180c05 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4804,8 +4804,12 @@ public: void tst_QGraphicsView::hoverLeave() { - if (platformName == QStringLiteral("cocoa")) + if (platformName == QStringLiteral("cocoa")) { QSKIP("Insignificant on OSX"); + } else if (platformName == QStringLiteral("minimal") + || (platformName == QStringLiteral("offscreen"))) { + QSKIP("Fails in minimal/offscreen platforms if forwardMouseDoubleClick has been run"); + } const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QGraphicsScene scene; QGraphicsView view(&scene); diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 4d57b85f9a..9a0ca0565e 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -824,6 +824,12 @@ void tst_QMenuBar::check_escKey() if (!QApplication::style()->inherits("QWindowsStyle")) return; + if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive) + || !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) { + QWARN("Skipping menu button test on minimal/offscreen platforms"); + return; + } + // If we press Down the popupmenu should be active again QTest::keyClick(static_cast(0), Qt::Key_Down ); QVERIFY( !menu.menus.at(0)->isActiveWindow() ); @@ -1196,6 +1202,11 @@ void tst_QMenuBar::task223138_triggered() void tst_QMenuBar::task256322_highlight() { + if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive) + || !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) { + QSKIP("Highlighting does not work correctly for minimal/offscreen platforms"); + } + QMainWindow win; win.menuBar()->setNativeMenuBar(false); //we can't check the geometry of native menubars QMenu menu; From be0a221ae491b8426b3a4cdf0d5863701e922c1f Mon Sep 17 00:00:00 2001 From: Filippo Cucchetto Date: Wed, 26 Apr 2017 12:49:36 +0200 Subject: [PATCH 11/12] Fix missing handling of columns when merging selection ranges This commit fixes two bugs: 1) Two ranges should not be merged if they are of different columns. The old code would have merged (0,0) with (1, 1). Tranforming a selection of just two indexes in a rectangle of four indexes. 2) The QItemSelectionRange appended had wrong column and worked only for indexes of the first column. For example if 'tl' was (0, 1) than br was (0, 1) so the QItemSelectionRange would have be ((0,1), (0, 1-1)) so ((0,1), (0,0)). This QItemSelectionRange is invalid because topLeft columns is greater than bottomRight column. The fix take in consideration the bottomRight column. Task-number: QTBUG-58871 Change-Id: I591ef0bcc63926f24a7b1ced002af9b7737a4b6e Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Qt CI Bot --- .../itemmodels/qitemselectionmodel.cpp | 3 +- .../tst_qitemselectionmodel.cpp | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 6c7101d41f..7714aa5e46 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -942,13 +942,14 @@ static QItemSelection mergeRowLengths(const QVector; + using IntPairList = QList; + using IntPairPair = std::pair; + using IntPairPairList = QList; + + QTest::addColumn("rangesToSelect"); + QTest::addColumn("expectedSelectedIndexesPairs"); + QTest::newRow("Single index in > 0 column") + << (IntPairPairList() << IntPairPair(IntPair(0, 1), IntPair(0, 1))) + << (IntPairList() << IntPair(0, 1)); + QTest::newRow("Rectangle in > 0 column") + << (IntPairPairList() << IntPairPair(IntPair(0, 1), IntPair(1, 2))) + << (IntPairList() << IntPair(0, 1) << IntPair(0, 2) << IntPair(1, 1) << IntPair(1, 2)); + QTest::newRow("Diagonal in > 0 column") + << (IntPairPairList() + << IntPairPair(IntPair(0, 1), IntPair(0, 1)) + << IntPairPair(IntPair(1, 2), IntPair(1, 2)) + << IntPairPair(IntPair(2, 3), IntPair(2, 3))) + << (IntPairList() + << IntPair(0, 1) + << IntPair(1, 2) + << IntPair(2, 3)); +} + +void tst_QItemSelectionModel::QTBUG58851() +{ + using IntPair = std::pair; + using IntPairList = QList; + using IntPairPair = std::pair; + using IntPairPairList = QList; + + QFETCH(IntPairPairList, rangesToSelect); + QFETCH(IntPairList, expectedSelectedIndexesPairs); + + QStandardItemModel model(4, 4); + for (int row = 0; row < model.rowCount(); ++row) { + for (int column = 0; column < model.columnCount(); ++column) { + QStandardItem *item = new QStandardItem(QString("%0%1").arg(row).arg(column)); + model.setItem(row, column, item); + } + } + + QSortFilterProxyModel proxy; + proxy.setSourceModel(&model); + proxy.setSortRole(Qt::DisplayRole); + + std::vector expectedSelectedIndexes; + for (const IntPair &index : expectedSelectedIndexesPairs) + expectedSelectedIndexes.emplace_back(proxy.index(index.first, index.second)); + + QItemSelectionModel selections(&proxy); + for (const IntPairPair &range : rangesToSelect) { + const IntPair &tl = range.first; + const IntPair &br = range.second; + selections.select(QItemSelection(proxy.index(tl.first, tl.second), + proxy.index(br.first, br.second)), + QItemSelectionModel::Select); + } + + for (const QPersistentModelIndex &i : expectedSelectedIndexes) { + QVERIFY(selections.isSelected(i)); + } + proxy.sort(1, Qt::DescendingOrder); + QCOMPARE(selections.selectedIndexes().count(), (int)expectedSelectedIndexes.size()); + for (const QPersistentModelIndex &i : expectedSelectedIndexes) { + QVERIFY(selections.isSelected(i)); + } +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" From 7f80c96432270e0097883e11e632c14cba68da28 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 8 May 2017 19:13:08 +0200 Subject: [PATCH 12/12] Stabilize tst_QApplication::touchEventPropagation CI metrics show that this test was flaky ~38 time in 3 days. The problem is old: after we get a surface, a window manager can still decide to re-position the window. The fix is to simply send the touch event in a position where it is sure to hit the window (usually the offset is the title bar height). The blacklisting seems to not have worked, I could reproduce the failure on a linux/xcb machine. Change-Id: I5229fe020ba75c984fd3b6c322ad00d769707573 Reviewed-by: Shawn Rutledge --- tests/auto/widgets/kernel/qapplication/BLACKLIST | 2 -- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST index 6abb1d9988..f4a9cb6166 100644 --- a/tests/auto/widgets/kernel/qapplication/BLACKLIST +++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST @@ -1,4 +1,2 @@ [quitOnLastWindowClosed] osx-10.10 -[touchEventPropagation] -xcb diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 49095b9625..b98cc048c8 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1987,7 +1987,7 @@ void tst_QApplication::touchEventPropagation() window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); const QPoint deviceGlobalPos = - QHighDpi::toNativePixels(window.mapToGlobal(QPoint(50, 50)), window.windowHandle()->screen()); + QHighDpi::toNativePixels(window.mapToGlobal(QPoint(50, 150)), window.windowHandle()->screen()); pressedTouchPoints[0].setScreenPos(deviceGlobalPos); releasedTouchPoints[0].setScreenPos(deviceGlobalPos);