From b3872572617789f1cb079452b675e532c19969a6 Mon Sep 17 00:00:00 2001 From: Sami Nurmenniemi Date: Thu, 23 Mar 2017 17:16:58 +0200 Subject: [PATCH 01/21] Fix layout tests for GCC 5.2.x/5.3.x GCC bug 68949 causes tst_QGraphicsGridLayout and tst_QGraphicsLinearLayout to fail on 5.2.x/5.3.x: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68949. This change adds aggregate initialization to QSizeF arrays to work around the bug. The bug was discovered when compiling and running tests on ARM with GCC 5.3.0. Change-Id: I9ecf7b032b6ca1477c29dca3bd7d0ec8d69a0454 Reviewed-by: Ville Voutilainen Reviewed-by: Thiago Macieira --- .../qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 9 ++++++--- .../qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 9d4b6402729..6924b78397d 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -150,7 +150,8 @@ public: m_fnConstraint = fnConstraint; } - QSizeF m_sizeHints[Qt::NSizeHints]; + // Initializer {} is a workaround for gcc bug 68949 + QSizeF m_sizeHints[Qt::NSizeHints] {}; QSizeF (*m_fnConstraint)(Qt::SizeHint, const QSizeF &); }; @@ -280,8 +281,10 @@ struct ItemDesc int m_rowSpan; int m_colSpan; QSizePolicy m_sizePolicy; - QSizeF m_sizeHints[Qt::NSizeHints]; - QSizeF m_sizes[Qt::NSizeHints]; + + // Initializer {} is a workaround for gcc bug 68949 + QSizeF m_sizeHints[Qt::NSizeHints] {}; + QSizeF m_sizes[Qt::NSizeHints] {}; Qt::Alignment m_align; Qt::Orientation m_constraintOrientation; diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 322af7c2367..0f5277710cb 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -165,7 +165,8 @@ public: return QGraphicsWidget::sizeHint(which, constraint); } - QSizeF m_sizeHints[Qt::NSizeHints]; + // Initializer {} is a workaround for gcc bug 68949 + QSizeF m_sizeHints[Qt::NSizeHints] {}; QBrush m_brush; }; From 2fbc1432025dd478cf9e940e3c2a1952b218c6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Tue, 28 Mar 2017 21:31:37 +0200 Subject: [PATCH 02/21] QtWidgets: Fix white text color on tabs on macOS for non-macOS styles Apply white text only for macOS style. Amends 2c0033983bc53e906eab3f4b2fae836ff8472713 Task-number: QTBUG-59784 Change-Id: I9e66e929699efd715ed4565394f1aba763aeb32a Reviewed-by: Jake Petroules --- src/widgets/widgets/qtabbar.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 35d94984132..f14e63c584e 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -176,12 +176,11 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex) if (tab.textColor.isValid()) option->palette.setColor(q->foregroundRole(), tab.textColor); -#ifdef Q_OS_MACOS - else if (isCurrent && !documentMode + else if (q->style()->inherits("QMacStyle") + && isCurrent && !documentMode && (QSysInfo::MacintoshVersion < QSysInfo::MV_10_10 || q->isActiveWindow())) { option->palette.setColor(QPalette::WindowText, Qt::white); } -#endif option->icon = tab.icon; option->iconSize = q->iconSize(); // Will get the default value then. From 9b5b44207ef9a191b0f45857232afdee8c938a04 Mon Sep 17 00:00:00 2001 From: Neils Nesse Date: Thu, 30 Mar 2017 14:23:23 -0700 Subject: [PATCH 03/21] Add new mkspec for cross-compiling Qt5 for AArch64 This mkspec provides default compiler settings for cross-compiling Qt5 for AArch64 Change-Id: I6318e150d7b48ad9c7364fce2a04ee49220a6b7e Reviewed-by: Jake Petroules --- mkspecs/linux-aarch64-gnu-g++/qmake.conf | 24 +++++++++++ mkspecs/linux-aarch64-gnu-g++/qplatformdefs.h | 40 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 mkspecs/linux-aarch64-gnu-g++/qmake.conf create mode 100644 mkspecs/linux-aarch64-gnu-g++/qplatformdefs.h diff --git a/mkspecs/linux-aarch64-gnu-g++/qmake.conf b/mkspecs/linux-aarch64-gnu-g++/qmake.conf new file mode 100644 index 00000000000..2dc57b09fae --- /dev/null +++ b/mkspecs/linux-aarch64-gnu-g++/qmake.conf @@ -0,0 +1,24 @@ +# +# qmake configuration for building with aarch64-linux-gnu-g++ +# + +MAKEFILE_GENERATOR = UNIX +CONFIG += incremental +QMAKE_INCREMENTAL_STYLE = sublib + +include(../common/linux.conf) +include(../common/gcc-base-unix.conf) +include(../common/g++-unix.conf) + +# modifications to g++.conf +QMAKE_CC = aarch64-linux-gnu-gcc +QMAKE_CXX = aarch64-linux-gnu-g++ +QMAKE_LINK = aarch64-linux-gnu-g++ +QMAKE_LINK_SHLIB = aarch64-linux-gnu-g++ + +# modifications to linux.conf +QMAKE_AR = aarch64-linux-gnu-ar cqs +QMAKE_OBJCOPY = aarch64-linux-gnu-objcopy +QMAKE_NM = aarch64-linux-gnu-nm -P +QMAKE_STRIP = aarch64-linux-gnu-strip +load(qt_config) diff --git a/mkspecs/linux-aarch64-gnu-g++/qplatformdefs.h b/mkspecs/linux-aarch64-gnu-g++/qplatformdefs.h new file mode 100644 index 00000000000..2697a75e442 --- /dev/null +++ b/mkspecs/linux-aarch64-gnu-g++/qplatformdefs.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../linux-g++/qplatformdefs.h" From 9a0d47bcf1f7988984c38f123828b93fdfc20a49 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 17 Mar 2017 14:33:33 -0700 Subject: [PATCH 04/21] tst_largefile: fix the mapOffsetOverflow case to match actual behavior Unix mmap(2) system calls do allow for mapping beyond the end of the file, though what happens after you try to dereference the pointers it gives is unspecified. POSIX[1] says that implementations shouldn't allow it: The system shall always zero-fill any partial page at the end of an object. Further, the system shall never write out any modified portions of the last page of an object which are beyond its end. References within the address range starting at pa and continuing for len bytes to whole pages following the end of an object shall result in delivery of a SIGBUS signal. However, Linux allows this in read-write mode and extends the file (depending on the filesystem). Windows MapViewOfFile never allows mapping beyond the end. [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html Change-Id: Ie67d35dff21147e99ad9fffd14acc8d9a1a0c38d Reviewed-by: Sami Nurmenniemi Reviewed-by: Teemu Holappa Reviewed-by: Thiago Macieira --- .../corelib/io/largefile/tst_largefile.cpp | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index a19a5ce58d2..7a174b79fd4 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -502,23 +502,42 @@ void tst_LargeFile::mapFile() } //Mac: memory-mapping beyond EOF may succeed but it could generate bus error on access +//FreeBSD: same +//Linux: memory-mapping beyond EOF usually succeeds, but depends on the filesystem +// 32-bit: limited to 44-bit offsets +//Windows: memory-mapping beyond EOF is not allowed void tst_LargeFile::mapOffsetOverflow() { -#ifndef Q_OS_MAC - // Out-of-range mappings should fail, and not silently clip the offset - for (int i = 50; i < 63; ++i) { + enum { +#ifdef Q_OS_WIN + Succeeds = false, + MaxOffset = 63 +#else + Succeeds = true, +# if (defined(Q_OS_LINUX) || defined(Q_OS_ANDROID)) && Q_PROCESSOR_WORDSIZE == 4 + MaxOffset = 43 +# else + MaxOffset = 63 +# endif +#endif + }; + + QByteArray zeroPage(blockSize, '\0'); + for (int i = maxSizeBits + 1; i < 63; ++i) { + bool succeeds = Succeeds && (i <= MaxOffset); uchar *address = 0; + qint64 offset = Q_INT64_C(1) << i; - address = largeFile.map(((qint64)1 << i), blockSize); -#if defined(__x86_64__) - QEXPECT_FAIL("", "fails on 64-bit Linux (QTBUG-21175)", Abort); -#endif - QVERIFY( !address ); + if (succeeds) + QTest::ignoreMessage(QtWarningMsg, "QFSFileEngine::map: Mapping a file beyond its size is not portable"); + address = largeFile.map(offset, blockSize); + QCOMPARE(!!address, succeeds); - address = largeFile.map(((qint64)1 << i) + blockSize, blockSize); - QVERIFY( !address ); + if (succeeds) + QTest::ignoreMessage(QtWarningMsg, "QFSFileEngine::map: Mapping a file beyond its size is not portable"); + address = largeFile.map(offset + blockSize, blockSize); + QCOMPARE(!!address, succeeds); } -#endif } QTEST_APPLESS_MAIN(tst_LargeFile) From cd9e850f9e9620a8bafec964efad8098443be7f1 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 30 Mar 2017 16:23:58 +0100 Subject: [PATCH 05/21] QCryptographicHash: fix documentation of the supported algorithms Change-Id: Idfa7843ef8a8e3410ae0a8cf5311b8b598299730 Reviewed-by: Thiago Macieira --- src/corelib/tools/qcryptographichash.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 08f89d2f02b..cdd7f6f4f63 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -196,7 +196,8 @@ public: QCryptographicHash can be used to generate cryptographic hashes of binary or text data. - Currently MD4, MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 are supported. + Refer to the documentation of the \l QCryptographicHash::Algorithm enum for a + list of the supported algorithms. */ /*! From 88a8feeacb9bdaff9ee06164424e407eb904cd10 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 28 Mar 2017 20:09:22 +0100 Subject: [PATCH 06/21] QCryptographicHash: make SHA3 calculate SHA3, not Keccak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SHA3 family is a modified version of Keccak. We were incorrectly calculating Keccak (and even *testing* Keccak!), but claiming it was SHA3. To actually calculate SHA3, we need invoke Keccak on the original message followed by the two bits sequence 0b01, cf. §6.1 [1]. [1] http://dx.doi.org/10.6028/NIST.FIPS.202 [ChangeLog][QtCore][QCryptographicHash] QCryptographicHash now properly calculates SHA3 message digests. Before, when asked to calculate a SHA3 digest, it calculated a Keccak digest instead. Task-number: QTBUG-59770 Change-Id: Iae694d1a1668aa676922e3e00a292cddc30d3e0d Reviewed-by: Thiago Macieira --- src/corelib/tools/qcryptographichash.cpp | 52 ++++-- .../tst_qcryptographichash.cpp | 154 +++++++++++------- 2 files changed, 136 insertions(+), 70 deletions(-) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index cdd7f6f4f63..963a91b9a97 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -180,9 +180,45 @@ public: SHA3Context sha3Context; #endif }; +#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 + void sha3Finish(int bitCount); +#endif QByteArray result; }; +#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 +void QCryptographicHashPrivate::sha3Finish(int bitCount) +{ + /* + FIPS 202 §6.1 defines SHA-3 in terms of calculating the Keccak function + over the original message with the two-bit suffix "01" appended to it. + This variable stores that suffix (and it's fed into the calculations + when the hash is returned to users). + + Only 2 bits of this variable are actually used (see the call to sha3Update + below). The Keccak implementation we're using will actually use the + *leftmost* 2 bits, and interpret them right-to-left. In other words, the + bits must appear in order of *increasing* significance; and as the two most + significant bits of the byte -- the rightmost 6 are ignored. (Yes, this + seems self-contradictory, but it's the way it is...) + + Overall, this means: + * the leftmost two bits must be "10" (not "01"!); + * we don't care what the other six bits are set to (they can be set to + any value), but we arbitrarily set them to 0; + + and for an unsigned char this gives us 0b10'00'00'00, or 0x80. + */ + static const unsigned char sha3FinalSuffix = 0x80; + + result.resize(bitCount / 8); + + SHA3Context copy = sha3Context; + sha3Update(©, reinterpret_cast(&sha3FinalSuffix), 2); + sha3Final(©, reinterpret_cast(result.data())); +} +#endif + /*! \class QCryptographicHash \inmodule QtCore @@ -427,27 +463,19 @@ QByteArray QCryptographicHash::result() const break; } case Sha3_224: { - SHA3Context copy = d->sha3Context; - d->result.resize(224/8); - sha3Final(©, reinterpret_cast(d->result.data())); + d->sha3Finish(224); break; } case Sha3_256: { - SHA3Context copy = d->sha3Context; - d->result.resize(256/8); - sha3Final(©, reinterpret_cast(d->result.data())); + d->sha3Finish(256); break; } case Sha3_384: { - SHA3Context copy = d->sha3Context; - d->result.resize(384/8); - sha3Final(©, reinterpret_cast(d->result.data())); + d->sha3Finish(384); break; } case Sha3_512: { - SHA3Context copy = d->sha3Context; - d->result.resize(512/8); - sha3Final(©, reinterpret_cast(d->result.data())); + d->sha3Finish(512); break; } #endif diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index dee10cbebc8..17a0f3edd92 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -30,6 +30,8 @@ #include #include +Q_DECLARE_METATYPE(QCryptographicHash::Algorithm) + class tst_QCryptographicHash : public QObject { Q_OBJECT @@ -39,6 +41,7 @@ private slots: void intermediary_result_data(); void intermediary_result(); void sha1(); + void sha3_data(); void sha3(); void files_data(); void files(); @@ -107,22 +110,47 @@ void tst_QCryptographicHash::intermediary_result_data() << QByteArray::fromHex("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F") << QByteArray::fromHex("F3C41E7B63EE869596FC28BAD64120612C520F65928AB4D126C72C6998B551B8FF1CEDDFED4373E6717554DC89D1EEE6F0AB22FD3675E561ABA9AE26A3EEC53B"); - QTest::newRow("sha3_224") << int(QCryptographicHash::Sha3_224) - << QByteArray("abc") << QByteArray("abc") - << QByteArray::fromHex("C30411768506EBE1C2871B1EE2E87D38DF342317300A9B97A95EC6A8") - << QByteArray::fromHex("048330E7C7C8B4A41AB713B3A6F958D77B8CF3EE969930F1584DD550"); - QTest::newRow("sha3_256") << int(QCryptographicHash::Sha3_256) - << QByteArray("abc") << QByteArray("abc") - << QByteArray::fromHex("4E03657AEA45A94FC7D47BA826C8D667C0D1E6E33A64A036EC44F58FA12D6C45") - << QByteArray::fromHex("9F0ADAD0A59B05D2E04A1373342B10B9EB16C57C164C8A3BFCBF46DCCEE39A21"); - QTest::newRow("sha3_384") << int(QCryptographicHash::Sha3_384) - << QByteArray("abc") << QByteArray("abc") - << QByteArray::fromHex("F7DF1165F033337BE098E7D288AD6A2F74409D7A60B49C36642218DE161B1F99F8C681E4AFAF31A34DB29FB763E3C28E") - << QByteArray::fromHex("D733B87D392D270889D3DA23AE113F349E25574B445F319CDE4CD3F877C753E9E3C65980421339B3A131457FF393939F"); - QTest::newRow("sha3_512") << int(QCryptographicHash::Sha3_512) - << QByteArray("abc") << QByteArray("abc") - << QByteArray::fromHex("18587DC2EA106B9A1563E32B3312421CA164C7F1F07BC922A9C83D77CEA3A1E5D0C69910739025372DC14AC9642629379540C17E2A65B19D77AA511A9D00BB96") - << QByteArray::fromHex("A7C392D2A42155761CA76BDDDE1C47D55486B007EDF465397BFB9DFA74D11C8F0D7C86CD29415283F1B5E7F655CEC25B869C9E9C33A8986F0B38542FB12BFB93"); + QTest::newRow("sha3_224_empty_abc") + << int(QCryptographicHash::Sha3_224) + << QByteArray("") << QByteArray("abc") + << QByteArray::fromHex("6B4E03423667DBB73B6E15454F0EB1ABD4597F9A1B078E3F5B5A6BC7") + << QByteArray::fromHex("E642824C3F8CF24AD09234EE7D3C766FC9A3A5168D0C94AD73B46FDF"); + QTest::newRow("sha3_256_empty_abc") + << int(QCryptographicHash::Sha3_256) + << QByteArray("") << QByteArray("abc") + << QByteArray::fromHex("A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A") + << QByteArray::fromHex("3A985DA74FE225B2045C172D6BD390BD855F086E3E9D525B46BFE24511431532"); + QTest::newRow("sha3_384_empty_abc") + << int(QCryptographicHash::Sha3_384) + << QByteArray("") << QByteArray("abc") + << QByteArray::fromHex("0C63A75B845E4F7D01107D852E4C2485C51A50AAAA94FC61995E71BBEE983A2AC3713831264ADB47FB6BD1E058D5F004") + << QByteArray::fromHex("EC01498288516FC926459F58E2C6AD8DF9B473CB0FC08C2596DA7CF0E49BE4B298D88CEA927AC7F539F1EDF228376D25"); + QTest::newRow("sha3_512_empty_abc") + << int(QCryptographicHash::Sha3_512) + << QByteArray("") << QByteArray("abc") + << QByteArray::fromHex("A69F73CCA23A9AC5C8B567DC185A756E97C982164FE25859E0D1DCC1475C80A615B2123AF1F5F94C11E3E9402C3AC558F500199D95B6D3E301758586281DCD26") + << QByteArray::fromHex("B751850B1A57168A5693CD924B6B096E08F621827444F70D884F5D0240D2712E10E116E9192AF3C91A7EC57647E3934057340B4CF408D5A56592F8274EEC53F0"); + + QTest::newRow("sha3_224_abc_abc") + << int(QCryptographicHash::Sha3_224) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("E642824C3F8CF24AD09234EE7D3C766FC9A3A5168D0C94AD73B46FDF") + << QByteArray::fromHex("58F426458091E16FBC61DDCB8F2D2A6F30F729CAFA3C289A4EB2BCF8"); + QTest::newRow("sha3_256_abc_abc") + << int(QCryptographicHash::Sha3_256) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("3A985DA74FE225B2045C172D6BD390BD855F086E3E9D525B46BFE24511431532") + << QByteArray::fromHex("6C0872716337DE1EE664C1E37F64ADE109448F02681C63A912BC230FDEFC0058"); + QTest::newRow("sha3_384_abc_abc") + << int(QCryptographicHash::Sha3_384) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("EC01498288516FC926459F58E2C6AD8DF9B473CB0FC08C2596DA7CF0E49BE4B298D88CEA927AC7F539F1EDF228376D25") + << QByteArray::fromHex("34FA93E11E467D610524EC91CEDC848EE1395BCF8F4F987455478E63DB0BCE47194D33D1251A3CC32BBB18D8726040D0"); + QTest::newRow("sha3_512_abc_abc") + << int(QCryptographicHash::Sha3_512) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("B751850B1A57168A5693CD924B6B096E08F621827444F70D884F5D0240D2712E10E116E9192AF3C91A7EC57647E3934057340B4CF408D5A56592F8274EEC53F0") + << QByteArray::fromHex("BB582DA40D15399ACF62AFCBBD6CFC9EE1DD5129B1EF9935DD3B21668F1A73D7841018BE3B13F281C3A8E9DA7EDB60F57B9F9F1C04033DF4CE3654B7B2ADB310"); } void tst_QCryptographicHash::intermediary_result() @@ -172,57 +200,67 @@ void tst_QCryptographicHash::sha1() QByteArray("34AA973CD4C4DAA4F61EEB2BDBAD27316534016F")); } -void tst_QCryptographicHash::sha3() +void tst_QCryptographicHash::sha3_data() { - // SHA3-224("The quick brown fox jumps over the lazy dog") - // 10aee6b30c47350576ac2873fa89fd190cdc488442f3ef654cf23fe - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog", - QCryptographicHash::Sha3_224).toHex(), - QByteArray("310aee6b30c47350576ac2873fa89fd190cdc488442f3ef654cf23fe")); - // SHA3-224("The quick brown fox jumps over the lazy dog.") - // c59d4eaeac728671c635ff645014e2afa935bebffdb5fbd207ffdeab - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog.", - QCryptographicHash::Sha3_224).toHex(), - QByteArray("c59d4eaeac728671c635ff645014e2afa935bebffdb5fbd207ffdeab")); + QTest::addColumn("algorithm"); + QTest::addColumn("data"); + QTest::addColumn("expectedResult"); - // SHA3-256("The quick brown fox jumps over the lazy dog") - // 4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15 - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog", - QCryptographicHash::Sha3_256).toHex(), - QByteArray("4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15")); +#define ROW(Tag, Algorithm, Input, Result) \ + QTest::newRow(Tag) << Algorithm << QByteArrayLiteral(Input) << QByteArray::fromHex(Result) - // SHA3-256("The quick brown fox jumps over the lazy dog.") - // 578951e24efd62a3d63a86f7cd19aaa53c898fe287d2552133220370240b572d - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog.", - QCryptographicHash::Sha3_256).toHex(), - QByteArray("578951e24efd62a3d63a86f7cd19aaa53c898fe287d2552133220370240b572d")); + ROW("sha3_224_pangram", + QCryptographicHash::Sha3_224, + "The quick brown fox jumps over the lazy dog", + "d15dadceaa4d5d7bb3b48f446421d542e08ad8887305e28d58335795"); - // SHA3-384("The quick brown fox jumps over the lazy dog") - // 283990fa9d5fb731d786c5bbee94ea4db4910f18c62c03d173fc0a5e494422e8a0b3da7574dae7fa0baf005e504063b3 - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog", - QCryptographicHash::Sha3_384).toHex(), - QByteArray("283990fa9d5fb731d786c5bbee94ea4db4910f18c62c03d173fc0a5e494422e8a0b3da7574dae7fa0baf005e504063b3")); + ROW("sha3_224_pangram_dot", + QCryptographicHash::Sha3_224, + "The quick brown fox jumps over the lazy dog.", + "2d0708903833afabdd232a20201176e8b58c5be8a6fe74265ac54db0"); - // SHA3-384("The quick brown fox jumps over the lazy dog.") - // 9ad8e17325408eddb6edee6147f13856ad819bb7532668b605a24a2d958f88bd5c169e56dc4b2f89ffd325f6006d820b - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog.", - QCryptographicHash::Sha3_384).toHex(), - QByteArray("9ad8e17325408eddb6edee6147f13856ad819bb7532668b605a24a2d958f88bd5c169e56dc4b2f89ffd325f6006d820b")); + ROW("sha3_256_pangram", + QCryptographicHash::Sha3_256, + "The quick brown fox jumps over the lazy dog", + "69070dda01975c8c120c3aada1b282394e7f032fa9cf32f4cb2259a0897dfc04"); - // SHA3-512("The quick brown fox jumps over the lazy dog") - // d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609 - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog", - QCryptographicHash::Sha3_512).toHex(), - QByteArray("d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609")); + ROW("sha3_256_pangram_dot", + QCryptographicHash::Sha3_256, + "The quick brown fox jumps over the lazy dog.", + "a80f839cd4f83f6c3dafc87feae470045e4eb0d366397d5c6ce34ba1739f734d"); - // SHA3-512("The quick brown fox jumps over the lazy dog.") - // ab7192d2b11f51c7dd744e7b3441febf397ca07bf812cceae122ca4ded6387889064f8db9230f173f6d1ab6e24b6e50f065b039f799f5592360a6558eb52d760 - QCOMPARE(QCryptographicHash::hash("The quick brown fox jumps over the lazy dog.", - QCryptographicHash::Sha3_512).toHex(), - QByteArray("ab7192d2b11f51c7dd744e7b3441febf397ca07bf812cceae122ca4ded6387889064f8db9230f173f6d1ab6e24b6e50f065b039f799f5592360a6558eb52d760")); + ROW("sha3_384_pangram", + QCryptographicHash::Sha3_384, + "The quick brown fox jumps over the lazy dog", + "7063465e08a93bce31cd89d2e3ca8f602498696e253592ed26f07bf7e703cf328581e1471a7ba7ab119b1a9ebdf8be41"); + + ROW("sha3_384_pangram_dot", + QCryptographicHash::Sha3_384, + "The quick brown fox jumps over the lazy dog.", + "1a34d81695b622df178bc74df7124fe12fac0f64ba5250b78b99c1273d4b080168e10652894ecad5f1f4d5b965437fb9"); + + ROW("sha3_512_pangram", + QCryptographicHash::Sha3_512, + "The quick brown fox jumps over the lazy dog", + "01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450"); + + ROW("sha3_512_pangram_dot", + QCryptographicHash::Sha3_512, + "The quick brown fox jumps over the lazy dog.", + "18f4f4bd419603f95538837003d9d254c26c23765565162247483f65c50303597bc9ce4d289f21d1c2f1f458828e33dc442100331b35e7eb031b5d38ba6460f8"); + +#undef ROW } -Q_DECLARE_METATYPE(QCryptographicHash::Algorithm); +void tst_QCryptographicHash::sha3() +{ + QFETCH(QCryptographicHash::Algorithm, algorithm); + QFETCH(QByteArray, data); + QFETCH(QByteArray, expectedResult); + + const auto result = QCryptographicHash::hash(data, algorithm); + QCOMPARE(result, expectedResult); +} void tst_QCryptographicHash::files_data() { QTest::addColumn("filename"); From 507223a218aa218e80dd9eae9bd3958efda301cf Mon Sep 17 00:00:00 2001 From: Tobias Sung Date: Fri, 31 Mar 2017 17:08:50 +0200 Subject: [PATCH 07/21] Don't use non-POD type as variadic argument Implicit conversion from QByteArray to const char* works for most gtk functions. But gtk_file_chooser_dialog_new() uses varargs and passing the non-POD QByteArray through varargs does not work (it's UB). Task-number: QTBUG-59763 Change-Id: I85f9323d99342896e6921cdeb85f5a1af7377b4f Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index 8b6ec31400a..eb7f0d8c2c1 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -245,8 +245,8 @@ QGtk3FileDialogHelper::QGtk3FileDialogHelper() { d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", 0, GTK_FILE_CHOOSER_ACTION_OPEN, - standardButtonText(QPlatformDialogHelper::Cancel), GTK_RESPONSE_CANCEL, - standardButtonText(QPlatformDialogHelper::Ok), GTK_RESPONSE_OK, + standardButtonText(QPlatformDialogHelper::Cancel).constData(), GTK_RESPONSE_CANCEL, + standardButtonText(QPlatformDialogHelper::Ok).constData(), GTK_RESPONSE_OK, NULL))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); From 62013d77721820976102581b4cbd31404c109903 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Mar 2017 11:46:26 -0800 Subject: [PATCH 08/21] Mark to remove const from function parameters in QtCore public headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some compilers are known to complain about this with a warning. GCC complains about const on return values on -Wignored-qualifiers (enabled at -Wextra), so it's not too much of a jump to assume that others do too. Besides, this is not Qt Library API policy. As maintainer for QtCore, I'm exercising my prerrogative in specifying certain unspecified parts of the coding style, like I've done for constructor initializer lists. Since all the classes involved are exported (including QVector, through derived classes), we can't remove the qualifier until Qt 6, since there are compilers known to encode the qualifier in the mangled name (suncc). I'm not introducing #ifdef to silence unknown compilers unless we get an actual complaint. Change-Id: I33850dcdb2ce4a47878efffd14a876edef843c46 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.h | 2 +- src/corelib/kernel/qvariant.h | 2 +- src/corelib/tools/qvector.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 7b0a9f986b9..5a903147352 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -526,7 +526,7 @@ public: static bool load(QDataStream &stream, int type, void *data); #endif - explicit QMetaType(const int type); + explicit QMetaType(const int type); // ### Qt6: drop const inline ~QMetaType(); inline bool isValid() const; diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index c0e5f2f591a..a2c5711993c 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -464,7 +464,7 @@ public: void create(int type, const void *copy); bool cmp(const QVariant &other) const; int compare(const QVariant &other) const; - bool convert(const int t, void *ptr) const; + bool convert(const int t, void *ptr) const; // ### Qt6: drop const private: // force compile error, prevent QVariant(bool) to be called diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index a526d35ddc9..e345163c2fd 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -291,6 +291,7 @@ public: private: friend class QRegion; // Optimization for QRegion::rects() + // ### Qt6: remove const from int parameters void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default); void reallocData(const int sz) { reallocData(sz, d->alloc); } void freeData(Data *d); From a03390a8b0318e30ae3b6dc9954093c137a20c32 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 4 Mar 2017 09:33:35 -0800 Subject: [PATCH 09/21] Detect the (stated) C++ standard edition at build time The configure-time detection (cxx11default) isn't enough if the compiler can be changed. This is especially necessary if Qt is compiled with a compiler that defaults to >= C++11 (e.g., GCC 6) and then the user selects a compiler another compiler (e.g., Clang) via -spec option. In that case, we'd miss adding the -std=c++11 or -std=gnu++11 option to the command-line, causing the compilation to fail. As a nice side-effect, even moc without moc_predefs.h will now get the __cplusplus setting. Task-number: QTBUG-58321 Change-Id: I74966ed02f674a7295f8fffd14a8be35da9640e1 Reviewed-by: Oswald Buddenhagen Reviewed-by: Marc Mutz --- .../common/c++98default/c++98default.cpp | 44 ------------------- .../common/c++98default/c++98default.pro | 3 -- configure.json | 10 ----- mkspecs/features/data/macros.cpp | 1 + mkspecs/features/default_post.prf | 5 +++ mkspecs/features/toolchain.prf | 1 + 6 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 config.tests/common/c++98default/c++98default.cpp delete mode 100644 config.tests/common/c++98default/c++98default.pro diff --git a/config.tests/common/c++98default/c++98default.cpp b/config.tests/common/c++98default/c++98default.cpp deleted file mode 100644 index 3ff92eda33e..00000000000 --- a/config.tests/common/c++98default/c++98default.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the configuration of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#if __cplusplus < 201103L -#error "compiler does not use c++11 or higher by default" -#endif - -int main(int, char **) {} diff --git a/config.tests/common/c++98default/c++98default.pro b/config.tests/common/c++98default/c++98default.pro deleted file mode 100644 index 97cf2d7b209..00000000000 --- a/config.tests/common/c++98default/c++98default.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = app -CONFIG -= c++11 c++14 c++1z -SOURCES = c++98default.cpp diff --git a/configure.json b/configure.json index d987832fba4..06a1e639fe1 100644 --- a/configure.json +++ b/configure.json @@ -245,11 +245,6 @@ "type": "compile", "test": "common/c++1z" }, - "cxx11default": { - "label": "compiler defaulting to C++11 or higher", - "type": "compile", - "test": "common/c++98default" - }, "precompile_header": { "label": "precompiled header support", "type": "compile", @@ -451,11 +446,6 @@ "condition": "call.crossCompile", "output": [ "publicConfig", "privateConfig", "crossCompile" ] }, - "cxx11default": { - "label": "Compiler defaults to C++11 or higher", - "condition": "!tests.cxx11default", - "output": [ { "type": "publicConfig", "name": "c++11" } ] - }, "compiler-flags": { "output": [ "compilerFlags" ] }, diff --git a/mkspecs/features/data/macros.cpp b/mkspecs/features/data/macros.cpp index 88473fb980b..e677dace12a 100644 --- a/mkspecs/features/data/macros.cpp +++ b/mkspecs/features/data/macros.cpp @@ -1,4 +1,5 @@ // Keep this file small. The pre-processed contents are eval'd by qmake. +QT_COMPILER_STDCXX = __cplusplus #ifdef _MSC_VER QMAKE_MSC_VER = _MSC_VER QMAKE_MSC_FULL_VER = _MSC_FULL_VER diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 60759b445e0..359191c2d38 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -95,6 +95,11 @@ breakpad { !isEmpty(QMAKE_STRIP):QMAKE_POST_LINK = $$QMAKE_POST_LINK$$escape_expand(\\n\\t)$$quote($$QMAKE_STRIP $$DEBUGFILENAME) } +!c++11:!c++14:!c++1z { + # Qt requires C++11 since 5.7, check if we need to force a compiler option + QT_COMPILER_STDCXX_no_L = $$replace(QT_COMPILER_STDCXX, "L$", "") + !greaterThan(QT_COMPILER_STDCXX_no_L, 199711): CONFIG += c++11 +} c++11|c++14|c++1z { # Disable special compiler flags for host builds !host_build|!cross_compile { diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 6d96eaf6893..46a9c5707ae 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -137,6 +137,7 @@ unset(target_prefix) # Populate QMAKE_COMPILER_DEFINES and some compatibility variables. # The $$format_number() calls strip leading zeros to avoid misinterpretation as octal. +QMAKE_COMPILER_DEFINES += __cplusplus=$$QT_COMPILER_STDCXX !isEmpty(QMAKE_MSC_VER) { QMAKE_COMPILER_DEFINES += _MSC_VER=$$QMAKE_MSC_VER _MSC_FULL_VER=$$QMAKE_MSC_FULL_VER QT_MSVC_MAJOR_VERSION = $$replace(QMAKE_MSC_FULL_VER, "(..)(..)(.*)", "\\1") From e0e6cbdacb7520a6d9906e16a517c9932702d1aa Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 13 Mar 2017 20:35:24 +0100 Subject: [PATCH 10/21] xcb: prevent dangling pointer when window focus changes With the current implementation, the QXcbConnection::m_focusWindow was holding a dangling pointer during the focus transition from a dying modal window to other modal window. 1) QXcbConnection::m_focusWindow holds a pointer to A; 2) A is closed; 3) relayFocusToModalWindow B; => m_focusWindow now points to a dead window. 4) We get a reply back from WM in a respone to relayFocusToModalWindow (_NET_ACTIVE_WINDOW) => m_focusWindow now points to a valid window. The fix is to update m_focusWindow to nullptr, when the current focus window was destroyed and the new focus window has not been set yet by WM. This patch actually solves a more general case - whenever we get a focus-out event, we should set m_focusWindow to nullptr. It is ok for none of the windows to be in-focus while focus transition is happening. The focusInPeeker will make sure to "optimize out" (when possible) this no-window-in-focus state, and GUI won't be bothered by this extra event. This is how things were working before relayFocusToModalWindow was introduced. Having a focus-relay mechanism in-between is ok, but it should not have changed the original behavior. Task-number: QTBUG-48391 Task-number: QTBUG-55197 Change-Id: I6fdda9de73f999dad84000059ce4b89c0d1a964c Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbconnection.cpp | 4 ++-- src/plugins/platforms/xcb/qxcbconnection.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 20 +++++++++----------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 5e600c740bd..5e52d4d80fa 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1382,9 +1382,9 @@ void QXcbEventReader::unlock() m_mutex.unlock(); } -void QXcbConnection::setFocusWindow(QXcbWindow *w) +void QXcbConnection::setFocusWindow(QWindow *w) { - m_focusWindow = w; + m_focusWindow = w ? static_cast(w->handle()) : nullptr; } void QXcbConnection::setMouseGrabber(QXcbWindow *w) { diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 01a97a187ab..22c7d1aa8ec 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -480,7 +480,7 @@ public: Qt::MouseButton translateMouseButton(xcb_button_t s); QXcbWindow *focusWindow() const { return m_focusWindow; } - void setFocusWindow(QXcbWindow *); + void setFocusWindow(QWindow *); QXcbWindow *mouseGrabber() const { return m_mouseGrabber; } void setMouseGrabber(QXcbWindow *); QXcbWindow *mousePressWindow() const { return m_mousePressWindow; } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 15ca68c663a..509bc9b038a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -941,7 +941,7 @@ void QXcbWindow::doFocusIn() if (relayFocusToModalWindow()) return; QWindow *w = static_cast(QObjectPrivate::get(window()))->eventReceiver(); - connection()->setFocusWindow(static_cast(w->handle())); + connection()->setFocusWindow(w); QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason); } @@ -949,7 +949,7 @@ static bool focusInPeeker(QXcbConnection *connection, xcb_generic_event_t *event { if (!event) { // FocusIn event is not in the queue, proceed with FocusOut normally. - QWindowSystemInterface::handleWindowActivated(0, Qt::ActiveWindowFocusReason); + QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason); return true; } uint response_type = event->response_type & ~0x80; @@ -974,12 +974,10 @@ static bool focusInPeeker(QXcbConnection *connection, xcb_generic_event_t *event void QXcbWindow::doFocusOut() { - if (relayFocusToModalWindow()) - return; - connection()->setFocusWindow(0); - // Do not set the active window to 0 if there is a FocusIn coming. - // There is however no equivalent for XPutBackEvent so register a - // callback for QXcbConnection instead. + connection()->setFocusWindow(nullptr); + relayFocusToModalWindow(); + // Do not set the active window to nullptr if there is a FocusIn coming. + // The FocusIn handler will update QXcbConnection::setFocusWindow() accordingly. connection()->addPeekFunc(focusInPeeker); } @@ -2834,14 +2832,14 @@ void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event) reason = Qt::OtherFocusReason; break; } - connection()->setFocusWindow(static_cast(window()->handle())); + connection()->setFocusWindow(window()); QWindowSystemInterface::handleWindowActivated(window(), reason); break; case XEMBED_FOCUS_OUT: if (window() == QGuiApplication::focusWindow() && !activeWindowChangeQueued(window())) { - connection()->setFocusWindow(0); - QWindowSystemInterface::handleWindowActivated(0); + connection()->setFocusWindow(nullptr); + QWindowSystemInterface::handleWindowActivated(nullptr); } break; } From c9f5607500a998d1f00737aca17ff73fb16775b8 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 21 Feb 2017 13:32:00 +0100 Subject: [PATCH 11/21] xcb: fix build when xlib is not present Remove Xutil.h include from qxcbmime.cpp as it does not use any Xlib APIs. Using API from Xutil.h requires Xlib as noted in Xutil.h: /* You must include before including this file */ Everywhere else we do check for presence of Xlib, before including Xutil.h And remove some useless #undef(s) Task-number: QTBUG-39665 Change-Id: Ibfd2341338fe7e902b47eae2df6b9dafe4ab962d Reviewed-by: Alexander Volkov Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbmime.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 7592eb28879..3ec8fa491f6 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -44,12 +44,6 @@ #include #include -#include - -#undef XCB_ATOM_STRING -#undef XCB_ATOM_PIXMAP -#undef XCB_ATOM_BITMAP - QT_BEGIN_NAMESPACE #if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) From e1d3c8e203cc6b47535a846a143b808894942446 Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Tue, 28 Mar 2017 08:39:33 +0200 Subject: [PATCH 12/21] qtconcurrent: correct whitespaces Change-Id: Idaec09b75767a072bd817416c3cc2b19e3a0e03b Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Oswald Buddenhagen --- .../qtconcurrentstoredfunctioncall.h | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/concurrent/qtconcurrentstoredfunctioncall.h b/src/concurrent/qtconcurrentstoredfunctioncall.h index 750ece1ef1e..eba6a1aad08 100644 --- a/src/concurrent/qtconcurrentstoredfunctioncall.h +++ b/src/concurrent/qtconcurrentstoredfunctioncall.h @@ -103,7 +103,7 @@ template class StoredMemberFunctionCall0 : public RunFunctionTask { public: - StoredMemberFunctionCall0(T (Class::*_fn)() , const Class &_object) + StoredMemberFunctionCall0(T (Class::*_fn)(), const Class &_object) : fn(_fn), object(_object){ } void runFunctor() override @@ -119,7 +119,7 @@ template class VoidStoredMemberFunctionCall0 : public RunFunctionTask { public: - VoidStoredMemberFunctionCall0(T (Class::*_fn)() , const Class &_object) + VoidStoredMemberFunctionCall0(T (Class::*_fn)(), const Class &_object) : fn(_fn), object(_object){ } void runFunctor() override @@ -150,7 +150,7 @@ public: this->result = (object.*fn)(); } private: - T (Class::*fn)()const; + T (Class::*fn)() const; const Class object; }; @@ -166,7 +166,7 @@ public: (object.*fn)(); } private: - T (Class::*fn)()const; + T (Class::*fn)() const; const Class object; }; @@ -181,7 +181,7 @@ template class StoredMemberFunctionPointerCall0 : public RunFunctionTask { public: - StoredMemberFunctionPointerCall0(T (Class::*_fn)() , Class *_object) + StoredMemberFunctionPointerCall0(T (Class::*_fn)(), Class *_object) : fn(_fn), object(_object){ } void runFunctor() override @@ -197,7 +197,7 @@ template class VoidStoredMemberFunctionPointerCall0 : public RunFunctionTask { public: - VoidStoredMemberFunctionPointerCall0(T (Class::*_fn)() , Class *_object) + VoidStoredMemberFunctionPointerCall0(T (Class::*_fn)(), Class *_object) : fn(_fn), object(_object){ } void runFunctor() override @@ -228,7 +228,7 @@ public: this->result = (object->*fn)(); } private: - T (Class::*fn)()const; + T (Class::*fn)() const; Class const *object; }; @@ -244,7 +244,7 @@ public: (object->*fn)(); } private: - T (Class::*fn)()const; + T (Class::*fn)() const; Class const *object; }; @@ -306,7 +306,7 @@ template class StoredMemberFunctionCall1 : public RunFunctionTask { public: - StoredMemberFunctionCall1(T (Class::*_fn)(Param1) , const Class &_object, const Arg1 &_arg1) + StoredMemberFunctionCall1(T (Class::*_fn)(Param1), const Class &_object, const Arg1 &_arg1) : fn(_fn), object(_object), arg1(_arg1){ } void runFunctor() override @@ -322,7 +322,7 @@ template class VoidStoredMemberFunctionCall1 : public RunFunctionTask { public: - VoidStoredMemberFunctionCall1(T (Class::*_fn)(Param1) , const Class &_object, const Arg1 &_arg1) + VoidStoredMemberFunctionCall1(T (Class::*_fn)(Param1), const Class &_object, const Arg1 &_arg1) : fn(_fn), object(_object), arg1(_arg1){ } void runFunctor() override @@ -353,7 +353,7 @@ public: this->result = (object.*fn)(arg1); } private: - T (Class::*fn)(Param1)const; + T (Class::*fn)(Param1) const; const Class object; Arg1 arg1; }; @@ -369,7 +369,7 @@ public: (object.*fn)(arg1); } private: - T (Class::*fn)(Param1)const; + T (Class::*fn)(Param1) const; const Class object; Arg1 arg1; }; @@ -384,7 +384,7 @@ template class StoredMemberFunctionPointerCall1 : public RunFunctionTask { public: - StoredMemberFunctionPointerCall1(T (Class::*_fn)(Param1) , Class *_object, const Arg1 &_arg1) + StoredMemberFunctionPointerCall1(T (Class::*_fn)(Param1), Class *_object, const Arg1 &_arg1) : fn(_fn), object(_object), arg1(_arg1){ } void runFunctor() override @@ -400,7 +400,7 @@ template class VoidStoredMemberFunctionPointerCall1 : public RunFunctionTask { public: - VoidStoredMemberFunctionPointerCall1(T (Class::*_fn)(Param1) , Class *_object, const Arg1 &_arg1) + VoidStoredMemberFunctionPointerCall1(T (Class::*_fn)(Param1), Class *_object, const Arg1 &_arg1) : fn(_fn), object(_object), arg1(_arg1){ } void runFunctor() override @@ -431,7 +431,7 @@ public: this->result = (object->*fn)(arg1); } private: - T (Class::*fn)(Param1)const; + T (Class::*fn)(Param1) const; Class const *object; Arg1 arg1; }; @@ -447,7 +447,7 @@ public: (object->*fn)(arg1); } private: - T (Class::*fn)(Param1)const; + T (Class::*fn)(Param1) const; Class const *object; Arg1 arg1; }; @@ -492,7 +492,7 @@ template struct VoidStoredFunctorPointerCall2: public RunFunctionTask { inline VoidStoredFunctorPointerCall2(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2) - : function(_function), arg1(_arg1), arg2(_arg2) {} + : function(_function), arg1(_arg1), arg2(_arg2) {} void runFunctor() override { (*function)(arg1, arg2); } FunctionPointer * function; Arg1 arg1; Arg2 arg2; @@ -509,7 +509,7 @@ template { public: - StoredMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) + StoredMemberFunctionCall2(T (Class::*_fn)(Param1, Param2), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } void runFunctor() override @@ -525,7 +525,7 @@ template { public: - VoidStoredMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) + VoidStoredMemberFunctionCall2(T (Class::*_fn)(Param1, Param2), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } void runFunctor() override @@ -556,7 +556,7 @@ public: this->result = (object.*fn)(arg1, arg2); } private: - T (Class::*fn)(Param1, Param2)const; + T (Class::*fn)(Param1, Param2) const; const Class object; Arg1 arg1; Arg2 arg2; }; @@ -572,7 +572,7 @@ public: (object.*fn)(arg1, arg2); } private: - T (Class::*fn)(Param1, Param2)const; + T (Class::*fn)(Param1, Param2) const; const Class object; Arg1 arg1; Arg2 arg2; }; @@ -587,7 +587,7 @@ template { public: - StoredMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) + StoredMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } void runFunctor() override @@ -603,7 +603,7 @@ template { public: - VoidStoredMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) + VoidStoredMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } void runFunctor() override @@ -634,7 +634,7 @@ public: this->result = (object->*fn)(arg1, arg2); } private: - T (Class::*fn)(Param1, Param2)const; + T (Class::*fn)(Param1, Param2) const; Class const *object; Arg1 arg1; Arg2 arg2; }; @@ -650,7 +650,7 @@ public: (object->*fn)(arg1, arg2); } private: - T (Class::*fn)(Param1, Param2)const; + T (Class::*fn)(Param1, Param2) const; Class const *object; Arg1 arg1; Arg2 arg2; }; @@ -712,7 +712,7 @@ template { public: - StoredMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) + StoredMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } void runFunctor() override @@ -728,7 +728,7 @@ template { public: - VoidStoredMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) + VoidStoredMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } void runFunctor() override @@ -759,7 +759,7 @@ public: this->result = (object.*fn)(arg1, arg2, arg3); } private: - T (Class::*fn)(Param1, Param2, Param3)const; + T (Class::*fn)(Param1, Param2, Param3) const; const Class object; Arg1 arg1; Arg2 arg2; Arg3 arg3; }; @@ -775,7 +775,7 @@ public: (object.*fn)(arg1, arg2, arg3); } private: - T (Class::*fn)(Param1, Param2, Param3)const; + T (Class::*fn)(Param1, Param2, Param3) const; const Class object; Arg1 arg1; Arg2 arg2; Arg3 arg3; }; @@ -790,7 +790,7 @@ template { public: - StoredMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) + StoredMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } void runFunctor() override @@ -806,7 +806,7 @@ template { public: - VoidStoredMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) + VoidStoredMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } void runFunctor() override @@ -837,7 +837,7 @@ public: this->result = (object->*fn)(arg1, arg2, arg3); } private: - T (Class::*fn)(Param1, Param2, Param3)const; + T (Class::*fn)(Param1, Param2, Param3) const; Class const *object; Arg1 arg1; Arg2 arg2; Arg3 arg3; }; @@ -853,7 +853,7 @@ public: (object->*fn)(arg1, arg2, arg3); } private: - T (Class::*fn)(Param1, Param2, Param3)const; + T (Class::*fn)(Param1, Param2, Param3) const; Class const *object; Arg1 arg1; Arg2 arg2; Arg3 arg3; }; @@ -915,7 +915,7 @@ template { public: - StoredMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) + StoredMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } void runFunctor() override @@ -931,7 +931,7 @@ template { public: - VoidStoredMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) + VoidStoredMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } void runFunctor() override @@ -962,7 +962,7 @@ public: this->result = (object.*fn)(arg1, arg2, arg3, arg4); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4)const; + T (Class::*fn)(Param1, Param2, Param3, Param4) const; const Class object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; @@ -978,7 +978,7 @@ public: (object.*fn)(arg1, arg2, arg3, arg4); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4)const; + T (Class::*fn)(Param1, Param2, Param3, Param4) const; const Class object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; @@ -993,7 +993,7 @@ template { public: - StoredMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) + StoredMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } void runFunctor() override @@ -1009,7 +1009,7 @@ template { public: - VoidStoredMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) + VoidStoredMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } void runFunctor() override @@ -1040,7 +1040,7 @@ public: this->result = (object->*fn)(arg1, arg2, arg3, arg4); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4)const; + T (Class::*fn)(Param1, Param2, Param3, Param4) const; Class const *object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; @@ -1056,7 +1056,7 @@ public: (object->*fn)(arg1, arg2, arg3, arg4); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4)const; + T (Class::*fn)(Param1, Param2, Param3, Param4) const; Class const *object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; @@ -1102,7 +1102,7 @@ struct VoidStoredFunctorPointerCall5: public RunFunctionTask { inline VoidStoredFunctorPointerCall5(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) {} - void runFunctor() override {(*function)(arg1, arg2, arg3, arg4, arg5); } + void runFunctor() override { (*function)(arg1, arg2, arg3, arg4, arg5); } FunctionPointer * function; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; @@ -1118,7 +1118,7 @@ template { public: - StoredMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) + StoredMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } void runFunctor() override @@ -1134,7 +1134,7 @@ template { public: - VoidStoredMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) , const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) + VoidStoredMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } void runFunctor() override @@ -1165,7 +1165,7 @@ public: this->result = (object.*fn)(arg1, arg2, arg3, arg4, arg5); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5)const; + T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; const Class object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; @@ -1181,7 +1181,7 @@ public: (object.*fn)(arg1, arg2, arg3, arg4, arg5); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5)const; + T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; const Class object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; @@ -1196,7 +1196,7 @@ template { public: - StoredMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) + StoredMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } void runFunctor() override @@ -1212,7 +1212,7 @@ template { public: - VoidStoredMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) + VoidStoredMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } void runFunctor() override @@ -1243,7 +1243,7 @@ public: this->result = (object->*fn)(arg1, arg2, arg3, arg4, arg5); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5)const; + T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; Class const *object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; @@ -1259,7 +1259,7 @@ public: (object->*fn)(arg1, arg2, arg3, arg4, arg5); } private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5)const; + T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; Class const *object; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; From c807dc3c122a2e21d6446231cd94f51cb0cf65d2 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 3 Apr 2017 20:48:33 +0100 Subject: [PATCH 13/21] Use fallthrough attributes only in C++ mode GCC 7 defines __has_cpp_attribute even when invoked as "gcc" (possibly, Clang does the same, according to a comment in the code, did not test myself). Hence, define the fallthrough declaration (as C++11 attributes) only when compiling as C++, otherwise we pick them up even in C mode, and they cause build failures. Change-Id: I3f13205e014bb1dea59ee3664b29111521a7eae3 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/global/qcompilerdetection.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 3b83d81f026..eacb7a04d70 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1328,15 +1328,14 @@ Q_ASSUME_IMPL(valueOfExpression);\ } while (0) +#if defined(__cplusplus) #if QT_HAS_CPP_ATTRIBUTE(fallthrough) # define Q_FALLTHROUGH() [[fallthrough]] -#elif defined(__cplusplus) -/* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */ -# if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) +#elif QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) # define Q_FALLTHROUGH() [[clang::fallthrough]] -# elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) +#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) # define Q_FALLTHROUGH() [[gnu::fallthrough]] -# endif +#endif #endif #ifndef Q_FALLTHROUGH # if defined(Q_CC_GNU) && Q_CC_GNU >= 700 From 6a83f9aa98760d0ed1ab4c216a28a10862e86f00 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 29 Mar 2017 16:38:54 -0700 Subject: [PATCH 14/21] Fix qReallocAligned for reallocation when alignment > 2*sizeof(void*) When we call realloc, the alignment of the new block may be different from the old one. When that happens, we need to memmove the data to the new position, before we start overwriting things. Task-number: QTBUG-59804 Change-Id: I27b55fdf514247549455fffd14b07ea78918a3d0 Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qmalloc.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index f83cecd4992..05676a0da26 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -40,6 +40,7 @@ #include "qplatformdefs.h" #include +#include /* Define the container allocation functions in a separate file, so that our @@ -79,8 +80,6 @@ void *qMallocAligned(size_t size, size_t alignment) void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment) { // fake an aligned allocation - Q_UNUSED(oldsize); - void *actualptr = oldptr ? static_cast(oldptr)[-1] : 0; if (alignment <= sizeof(void*)) { // special, fast case @@ -110,9 +109,15 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align quintptr faked = reinterpret_cast(real) + alignment; faked &= ~(alignment - 1); - void **faked_ptr = reinterpret_cast(faked); + if (oldptr) { + qptrdiff oldoffset = static_cast(oldptr) - static_cast(actualptr); + qptrdiff newoffset = reinterpret_cast(faked_ptr) - static_cast(real); + if (oldoffset != newoffset) + memmove(faked_ptr, static_cast(real) + oldoffset, qMin(oldsize, newsize)); + } + // now save the value of the real pointer at faked-sizeof(void*) // by construction, alignment > sizeof(void*) and is a power of 2, so // faked-sizeof(void*) is properly aligned for a pointer From 5b78fcd03b63241fa0382aa196afe789740fd5b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 28 Mar 2017 12:23:44 +0200 Subject: [PATCH 15/21] QRasterBackingStore: Correct high-dpi image size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix QT_SCALE_FACTOR usage on macOS. Follow-up to 2d2d9078 QRasterBackingStore should account for native scaling only. Any Qt scaling will have already been factored into the size argument. Change-Id: I26a67addfcbec3d45f4ed87f03b8dd79fd99cb62 Reviewed-by: Tor Arne Vestbø --- .../graphics/qrasterbackingstore.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/platformsupport/graphics/qrasterbackingstore.cpp b/src/platformsupport/graphics/qrasterbackingstore.cpp index ef26edc494d..2f7074403ce 100644 --- a/src/platformsupport/graphics/qrasterbackingstore.cpp +++ b/src/platformsupport/graphics/qrasterbackingstore.cpp @@ -42,6 +42,9 @@ #include #include +#include +#include + QT_BEGIN_NAMESPACE QRasterBackingStore::QRasterBackingStore(QWindow *window) @@ -57,14 +60,14 @@ void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContent { Q_UNUSED(staticContents); - int windowDevicePixelRatio = window()->devicePixelRatio(); - QSize effectiveBufferSize = size * windowDevicePixelRatio; + qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio(); + QSize effectiveBufferSize = size * nativeWindowDevicePixelRatio; if (m_image.size() == effectiveBufferSize) return; m_image = QImage(effectiveBufferSize, format()); - m_image.setDevicePixelRatio(windowDevicePixelRatio); + m_image.setDevicePixelRatio(nativeWindowDevicePixelRatio); if (m_image.format() == QImage::Format_ARGB32_Premultiplied) m_image.fill(Qt::transparent); } @@ -106,8 +109,11 @@ bool QRasterBackingStore::scroll(const QRegion ®ion, int dx, int dy) void QRasterBackingStore::beginPaint(const QRegion ®ion) { // Keep backing store device pixel ratio in sync with window - if (m_image.devicePixelRatio() != window()->devicePixelRatio()) - resize(backingStore()->size(), backingStore()->staticContents()); + qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio(); + if (m_image.devicePixelRatio() != nativeWindowDevicePixelRatio) { + const QSize nativeSize = QHighDpi::toNativePixels(backingStore()->size(), window()); + resize(nativeSize, backingStore()->staticContents()); + } if (!m_image.hasAlphaChannel()) return; From ecceaec8581886e5215ab10c8f5c702e315cb397 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 3 Apr 2017 20:53:17 +0100 Subject: [PATCH 16/21] GCC 7: fix -Werror=implicit-fallthrough More fallthrough-are-errors fixed. Change-Id: I9a6cb6efe988400ed3f9cb95d1e426dac317e6c4 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Marc Mutz --- src/corelib/xml/qxmlstream_p.h | 1 + src/gui/painting/qblendfunctions_p.h | 12 +++---- src/gui/painting/qdrawhelper_p.h | 42 +++++++++++----------- src/gui/painting/qgrayraster.c | 14 ++++---- src/gui/painting/qtransform.cpp | 6 +++- src/gui/text/qtextengine.cpp | 7 +++- src/widgets/styles/qcommonstyle.cpp | 7 ++++ src/widgets/styles/qfusionstyle.cpp | 6 ++++ src/widgets/styles/qstylesheetstyle.cpp | 4 +-- src/widgets/widgets/qabstractspinbox.cpp | 2 ++ src/widgets/widgets/qdatetimeedit.cpp | 1 + src/widgets/widgets/qeffects.cpp | 1 + src/widgets/widgets/qtoolbar.cpp | 2 +- src/widgets/widgets/qwidgetlinecontrol.cpp | 1 + 14 files changed, 68 insertions(+), 38 deletions(-) diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index b62cc9ac392..9ef95c1fbe6 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -1139,6 +1139,7 @@ bool QXmlStreamReaderPrivate::parse() case '\n': ++lineNumber; lastLineStart = characterOffset + readBufferPos; + Q_FALLTHROUGH(); case ' ': case '\t': token = SPACE; diff --git a/src/gui/painting/qblendfunctions_p.h b/src/gui/painting/qblendfunctions_p.h index 7ee04987fef..167f7251439 100644 --- a/src/gui/painting/qblendfunctions_p.h +++ b/src/gui/painting/qblendfunctions_p.h @@ -375,12 +375,12 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl, --ii; } switch (i & 7) { - case 7: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; - case 6: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; - case 5: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; - case 4: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; - case 3: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; - case 2: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; + case 7: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 6: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 5: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 4: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 3: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 2: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); case 1: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; } diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 0e46962784a..694959909b3 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -846,13 +846,13 @@ inline void qt_memfill(T *dest, T value, int count) int n = (count + 7) / 8; switch (count & 0x07) { - case 0: do { *dest++ = value; - case 7: *dest++ = value; - case 6: *dest++ = value; - case 5: *dest++ = value; - case 4: *dest++ = value; - case 3: *dest++ = value; - case 2: *dest++ = value; + case 0: do { *dest++ = value; Q_FALLTHROUGH(); + case 7: *dest++ = value; Q_FALLTHROUGH(); + case 6: *dest++ = value; Q_FALLTHROUGH(); + case 5: *dest++ = value; Q_FALLTHROUGH(); + case 4: *dest++ = value; Q_FALLTHROUGH(); + case 3: *dest++ = value; Q_FALLTHROUGH(); + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest++ = value; } while (--n > 0); } @@ -888,13 +888,13 @@ do { \ int n = ((length) + 7) / 8; \ switch ((length) & 0x07) \ { \ - case 0: do { *--_d = *--_s; \ - case 7: *--_d = *--_s; \ - case 6: *--_d = *--_s; \ - case 5: *--_d = *--_s; \ - case 4: *--_d = *--_s; \ - case 3: *--_d = *--_s; \ - case 2: *--_d = *--_s; \ + case 0: do { *--_d = *--_s; Q_FALLTHROUGH(); \ + case 7: *--_d = *--_s; Q_FALLTHROUGH(); \ + case 6: *--_d = *--_s; Q_FALLTHROUGH(); \ + case 5: *--_d = *--_s; Q_FALLTHROUGH(); \ + case 4: *--_d = *--_s; Q_FALLTHROUGH(); \ + case 3: *--_d = *--_s; Q_FALLTHROUGH(); \ + case 2: *--_d = *--_s; Q_FALLTHROUGH(); \ case 1: *--_d = *--_s; \ } while (--n > 0); \ } \ @@ -908,13 +908,13 @@ do { \ int n = ((length) + 7) / 8; \ switch ((length) & 0x07) \ { \ - case 0: do { *_d++ = *_s++; \ - case 7: *_d++ = *_s++; \ - case 6: *_d++ = *_s++; \ - case 5: *_d++ = *_s++; \ - case 4: *_d++ = *_s++; \ - case 3: *_d++ = *_s++; \ - case 2: *_d++ = *_s++; \ + case 0: do { *_d++ = *_s++; Q_FALLTHROUGH(); \ + case 7: *_d++ = *_s++; Q_FALLTHROUGH(); \ + case 6: *_d++ = *_s++; Q_FALLTHROUGH(); \ + case 5: *_d++ = *_s++; Q_FALLTHROUGH(); \ + case 4: *_d++ = *_s++; Q_FALLTHROUGH(); \ + case 3: *_d++ = *_s++; Q_FALLTHROUGH(); \ + case 2: *_d++ = *_s++; Q_FALLTHROUGH(); \ case 1: *_d++ = *_s++; \ } while (--n > 0); \ } \ diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index db3453898f4..dae1c06beca 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -162,6 +162,8 @@ #include #include +#include + #include #include @@ -1147,12 +1149,12 @@ switch ( spans->len ) { - case 7: *q++ = (unsigned char)coverage; - case 6: *q++ = (unsigned char)coverage; - case 5: *q++ = (unsigned char)coverage; - case 4: *q++ = (unsigned char)coverage; - case 3: *q++ = (unsigned char)coverage; - case 2: *q++ = (unsigned char)coverage; + case 7: *q++ = (unsigned char)coverage; Q_FALLTHROUGH(); + case 6: *q++ = (unsigned char)coverage; Q_FALLTHROUGH(); + case 5: *q++ = (unsigned char)coverage; Q_FALLTHROUGH(); + case 4: *q++ = (unsigned char)coverage; Q_FALLTHROUGH(); + case 3: *q++ = (unsigned char)coverage; Q_FALLTHROUGH(); + case 2: *q++ = (unsigned char)coverage; Q_FALLTHROUGH(); case 1: *q = (unsigned char)coverage; default: ; diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 2d841b29536..4e0489b352b 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -2094,7 +2094,8 @@ QTransform::TransformationType QTransform::type() const if (!qFuzzyIsNull(m_13) || !qFuzzyIsNull(m_23) || !qFuzzyIsNull(m_33 - 1)) { m_type = TxProject; break; - } + } + Q_FALLTHROUGH(); case TxShear: case TxRotate: if (!qFuzzyIsNull(affine._m12) || !qFuzzyIsNull(affine._m21)) { @@ -2105,16 +2106,19 @@ QTransform::TransformationType QTransform::type() const m_type = TxShear; break; } + Q_FALLTHROUGH(); case TxScale: if (!qFuzzyIsNull(affine._m11 - 1) || !qFuzzyIsNull(affine._m22 - 1)) { m_type = TxScale; break; } + Q_FALLTHROUGH(); case TxTranslate: if (!qFuzzyIsNull(affine._dx) || !qFuzzyIsNull(affine._dy)) { m_type = TxTranslate; break; } + Q_FALLTHROUGH(); case TxNone: m_type = TxNone; break; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 67cafa53fe7..4f052dafd7a 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -579,12 +579,14 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon else eor = current; status.eor = QChar::DirEN; - dir = QChar::DirAN; break; + dir = QChar::DirAN; + break; case QChar::DirES: case QChar::DirCS: if(status.eor == QChar::DirEN || dir == QChar::DirAN) { eor = current; break; } + Q_FALLTHROUGH(); case QChar::DirBN: case QChar::DirB: case QChar::DirS: @@ -614,11 +616,13 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon eor = current; status.eor = dirCurrent; } } + break; default: break; } break; } + Q_FALLTHROUGH(); case QChar::DirAN: hasBidi = true; dirCurrent = QChar::DirAN; @@ -642,6 +646,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon if(status.eor == QChar::DirAN) { eor = current; break; } + Q_FALLTHROUGH(); case QChar::DirES: case QChar::DirET: case QChar::DirBN: diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 7971bd0b8bf..69c9230b4b5 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -3008,6 +3008,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r = subElementRect(SE_CheckBoxIndicator, opt, widget); break; } + Q_FALLTHROUGH(); case SE_ItemViewItemDecoration: case SE_ItemViewItemText: case SE_ItemViewItemFocusRect: @@ -4180,11 +4181,13 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex case SC_TitleBarContextHelpButton: if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) offset += delta; + Q_FALLTHROUGH(); case SC_TitleBarMinButton: if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) offset += delta; else if (sc == SC_TitleBarMinButton) break; + Q_FALLTHROUGH(); case SC_TitleBarNormalButton: if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) offset += delta; @@ -4192,21 +4195,25 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex offset += delta; else if (sc == SC_TitleBarNormalButton) break; + Q_FALLTHROUGH(); case SC_TitleBarMaxButton: if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) offset += delta; else if (sc == SC_TitleBarMaxButton) break; + Q_FALLTHROUGH(); case SC_TitleBarShadeButton: if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) offset += delta; else if (sc == SC_TitleBarShadeButton) break; + Q_FALLTHROUGH(); case SC_TitleBarUnshadeButton: if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) offset += delta; else if (sc == SC_TitleBarUnshadeButton) break; + Q_FALLTHROUGH(); case SC_TitleBarCloseButton: if (tb->titleBarFlags & Qt::WindowSystemMenuHint) offset += delta; diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index f1cd48556c1..6f61bff4038 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -3556,11 +3556,13 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom case SC_TitleBarContextHelpButton: if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) offset += delta; + Q_FALLTHROUGH(); case SC_TitleBarMinButton: if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) offset += delta; else if (sc == SC_TitleBarMinButton) break; + Q_FALLTHROUGH(); case SC_TitleBarNormalButton: if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) offset += delta; @@ -3568,21 +3570,25 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom offset += delta; else if (sc == SC_TitleBarNormalButton) break; + Q_FALLTHROUGH(); case SC_TitleBarMaxButton: if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) offset += delta; else if (sc == SC_TitleBarMaxButton) break; + Q_FALLTHROUGH(); case SC_TitleBarShadeButton: if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) offset += delta; else if (sc == SC_TitleBarShadeButton) break; + Q_FALLTHROUGH(); case SC_TitleBarUnshadeButton: if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) offset += delta; else if (sc == SC_TitleBarUnshadeButton) break; + Q_FALLTHROUGH(); case SC_TitleBarCloseButton: if (tb->titleBarFlags & Qt::WindowSystemMenuHint) offset += delta; diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 9be19b26799..6b0909ceb17 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4371,7 +4371,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op break; } #endif - //fall tghought + Q_FALLTHROUGH(); case PE_PanelMenu: case PE_PanelStatusBar: if(rule.hasDrawable()) { @@ -4928,7 +4928,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op case CT_ToolButton: if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw()) sz += QSize(3, 3); // ### broken QToolButton - //fall thought + Q_FALLTHROUGH(); case CT_ComboBox: case CT_PushButton: if (rule.hasBox() || !rule.hasNativeBorder()) { diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 8ccad5c35df..139ca0bc35d 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -976,6 +976,7 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) case Qt::Key_PageDown: steps *= 10; isPgUpOrDown = true; + Q_FALLTHROUGH(); case Qt::Key_Up: case Qt::Key_Down: { #ifdef QT_KEYPAD_NAVIGATION @@ -2111,6 +2112,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant case QVariant::Invalid: if (arg2.type() == QVariant::Invalid) return 0; + Q_FALLTHROUGH(); default: Q_ASSERT_X(0, "QAbstractSpinBoxPrivate::variantCompare", qPrintable(QString::fromLatin1("Internal error 3 (%1 %2)"). diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index c5eab55a536..2ca09800de5 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1113,6 +1113,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event) && !(event->modifiers() & ~(Qt::ShiftModifier|Qt::KeypadModifier)); break; } + Q_FALLTHROUGH(); case Qt::Key_Left: case Qt::Key_Right: if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) { diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index ecd85c2ca73..736f2599fe9 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -196,6 +196,7 @@ bool QAlphaWidget::eventFilter(QObject *o, QEvent *e) case QEvent::Close: if (o != widget) break; + Q_FALLTHROUGH(); case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: showWidget = false; diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 2a0912df0a4..48fa88b7a02 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -1143,7 +1143,7 @@ bool QToolBar::event(QEvent *event) case QEvent::Hide: if (!isHidden()) break; - // fallthrough intended + Q_FALLTHROUGH(); case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); #ifdef Q_OS_OSX diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index a862274a3dc..363e7157ac5 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1030,6 +1030,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) break; case '\\': escape = true; + Q_FALLTHROUGH(); default: s = true; break; From 83486f362b02070e29b408be3a9673a0b04dc424 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 4 Apr 2017 13:12:00 +0200 Subject: [PATCH 17/21] Adds a note to QSqlDatabase::~QSqlDatabase documentation When the last QSqlDatabase object is destroyed the destructor implicitly calls close() to release the database connection. Task-number: QTBUG-59919 Change-Id: I04c15c4999cdaaa8800a44a1a1006f977a90d8a6 Reviewed-by: Samuel Gaist Reviewed-by: Andy Shaw --- src/sql/kernel/qsqldatabase.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 0416215870e..412658e39c6 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -695,6 +695,9 @@ void QSqlDatabasePrivate::init(const QString &type) /*! Destroys the object and frees any allocated resources. + \note When the last connection is destroyed, the destructor + implicitly calls close() to release the database connection. + \sa close() */ From 6b52039866db6629747faa0aa1b57c206ed1cd6f Mon Sep 17 00:00:00 2001 From: Hendrick Melo Date: Tue, 14 Mar 2017 13:45:49 -0400 Subject: [PATCH 18/21] qbmphandler fix: use qint64 for caching QIODevice file position Changed the file position and offset types so they can properly handle files larger than the 32bit limit Task-number: QTBUG-59493 Change-Id: I00e1741c7682c4c79f35fef808fe1ea26e67c8b5 Reviewed-by: Marc Mutz Reviewed-by: Eirik Aavitsland Reviewed-by: Hendrick Melo --- src/gui/image/qbmphandler.cpp | 6 +++--- src/gui/image/qbmphandler_p.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 9545abfd219..324fe014147 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -183,14 +183,14 @@ static bool read_dib_infoheader(QDataStream &s, BMP_INFOHDR &bi) return true; } -static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int startpos, QImage &image) +static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset, qint64 startpos, QImage &image) { QIODevice* d = s.device(); if (d->atEnd()) // end of stream/file return false; #if 0 - qDebug("offset...........%d", offset); - qDebug("startpos.........%d", startpos); + qDebug("offset...........%lld", offset); + qDebug("startpos.........%lld", startpos); qDebug("biSize...........%d", bi.biSize); qDebug("biWidth..........%d", bi.biWidth); qDebug("biHeight.........%d", bi.biHeight); diff --git a/src/gui/image/qbmphandler_p.h b/src/gui/image/qbmphandler_p.h index 7d3cbab3226..3e1fc3d511b 100644 --- a/src/gui/image/qbmphandler_p.h +++ b/src/gui/image/qbmphandler_p.h @@ -121,7 +121,7 @@ private: State state; BMP_FILEHDR fileHeader; BMP_INFOHDR infoHeader; - int startpos; + qint64 startpos; }; QT_END_NAMESPACE From 9ae028f507a22bd03c861e9d14c2efc4aa2efeda Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 10 Feb 2017 15:00:23 +0100 Subject: [PATCH 19/21] Environment variable enabling the workaround FBO readback bug On some ARM devices the font glyph generation is broken Add an environment variable to enable workaround_brokenFBOReadBack in QOpenGLContext, to fix font rendering on such devices as Mali and Adreno Change-Id: I9cc99ecb8b71a35bc369ec9dd11b877016b1179e Reviewed-by: Laszlo Agocs --- src/gui/kernel/qopenglcontext.cpp | 34 +++++++++++++++++++ .../android/qandroidplatformopenglcontext.cpp | 31 ----------------- .../android/qandroidplatformopenglcontext.h | 1 - 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 8aea593bf08..3dc06ae60ed 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -982,6 +982,40 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this); if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) { + static bool needsWorkaroundSet = false; + static bool needsWorkaround = false; + + if (!needsWorkaroundSet) { + QByteArray env; +#ifdef Q_OS_ANDROID + env = qgetenv(QByteArrayLiteral("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND")); + needsWorkaround = env.isEmpty() || env == QByteArrayLiteral("0") || env == QByteArrayLiteral("false"); +#endif + env = qgetenv(QByteArrayLiteral("QT_ENABLE_GLYPH_CACHE_WORKAROUND")); + if (env == QByteArrayLiteral("1") || env == QByteArrayLiteral("true")) + needsWorkaround = true; + + if (!needsWorkaround) { + const char *rendererString = reinterpret_cast(functions()->glGetString(GL_RENDERER)); + if (rendererString) + needsWorkaround = + qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450 + || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205 + || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)' + || qstrncmp(rendererString, "Adreno (TM) 30x", 14) == 0 // Adreno 302, 305 + || qstrncmp(rendererString, "Adreno 30x", 9) == 0 // Same as above but without the '(TM)' + || qstrncmp(rendererString, "Adreno (TM) 4xx", 13) == 0 // Adreno 405, 418, 420, 430 + || qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)' + || qstrcmp(rendererString, "GC800 core") == 0 + || qstrcmp(rendererString, "GC1000 core") == 0 + || qstrcmp(rendererString, "Immersion.16") == 0; + } + needsWorkaroundSet = true; + } + + if (needsWorkaround) + d->workaround_brokenFBOReadBack = true; + d->surface = surface; d->shareGroup->d_func()->deletePendingResources(this); diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp index 4d52085a83f..6f979f614cc 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp @@ -65,42 +65,11 @@ void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface) QEGLPlatformContext::swapBuffers(surface); } -bool QAndroidPlatformOpenGLContext::needsFBOReadBackWorkaround() -{ - static bool set = false; - static bool needsWorkaround = false; - - if (!set) { - QByteArray env = qgetenv("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND"); - needsWorkaround = env.isEmpty() || env == "0" || env == "false"; - - if (!needsWorkaround) { - const char *rendererString = reinterpret_cast(glGetString(GL_RENDERER)); - needsWorkaround = - qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450 - || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205 - || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)' - || qstrncmp(rendererString, "Adreno (TM) 30x", 14) == 0 // Adreno 302, 305 - || qstrncmp(rendererString, "Adreno 30x", 9) == 0 // Same as above but without the '(TM)' - || qstrcmp(rendererString, "GC800 core") == 0 - || qstrcmp(rendererString, "GC1000 core") == 0 - || qstrcmp(rendererString, "Immersion.16") == 0; - } - - set = true; - } - - return needsWorkaround; -} - bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface) { bool ret = QEGLPlatformContext::makeCurrent(surface); QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); - if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaround()) - ctx_d->workaround_brokenFBOReadBack = true; - return ret; } diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.h b/src/plugins/platforms/android/qandroidplatformopenglcontext.h index 3897b3166be..8e65b4cc369 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.h +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.h @@ -55,7 +55,6 @@ public: private: EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override; - static bool needsFBOReadBackWorkaround(); }; QT_END_NAMESPACE From b67b80b71516af71fec28732506c25ad338a84e7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 4 Apr 2017 17:00:53 +0200 Subject: [PATCH 20/21] Fix stretch of QRawFonts Set stretch to always have no transform on raw fonts. Task-number: QTBUG-59799 Change-Id: Ibfacc5c247e0b4a8410572e207f09f6e67b74f9d Reviewed-by: Konstantin Tokarev Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index 0826b0f2fb4..8cf572b1af7 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -152,6 +152,7 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QByteArray &fontData, qreal pi { QFontDef fontDef; fontDef.pixelSize = pixelSize; + fontDef.stretch = QFont::Unstretched; fontDef.hintingPreference = hintingPreference; QFontEngineFTRawData *fe = new QFontEngineFTRawData(fontDef); From efb84b6189f9e98c6dd29c22f00ad760445196c2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 27 Mar 2017 15:48:37 +0200 Subject: [PATCH 21/21] Copy stretch to multifont fontDef If we do not the fontDef of the multifont will be the default 0. Task-number: QTBUG-59443 Change-Id: Ib223517975b2a57b2371e309d12cd8f918d30825 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qpdf.cpp | 2 ++ .../windows/qwindowsfontengine.cpp | 2 ++ .../painting/qpdfwriter/tst_qpdfwriter.cpp | 26 +++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 7b53966f81f..644999e00a2 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -2556,6 +2556,7 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti) qreal size = ti.fontEngine->fontDef.pixelSize; int synthesized = ti.fontEngine->synthesized(); qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.; + Q_ASSERT(stretch > qreal(0)); QTransform trans; // Build text rendering matrix (Trm). We need it to map the text area to user @@ -2632,6 +2633,7 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti) return; int synthesized = ti.fontEngine->synthesized(); qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.; + Q_ASSERT(stretch > qreal(0)); *currentPage << "BT\n" << "/F" << font->object_id << size << "Tf " diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp index 08ebbc3be01..5af73a6f2b9 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp @@ -1293,6 +1293,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at) fedw->fontDef.style = fontEngine->fontDef.style; fedw->fontDef.family = fam; fedw->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference; + fedw->fontDef.stretch = fontEngine->fontDef.stretch; return fedw; } else { qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__); @@ -1310,6 +1311,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at) fe->fontDef.style = fontEngine->fontDef.style; fe->fontDef.family = fam; fe->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference; + fe->fontDef.stretch = fontEngine->fontDef.stretch; return fe; } diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp index 00e00ecd6bc..c1a8f7f0de1 100644 --- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp +++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp @@ -29,8 +29,11 @@ #include #include #include +#include #include #include +#include +#include class tst_QPdfWriter : public QObject { @@ -40,6 +43,7 @@ private slots: void basics(); void testPageMetrics_data(); void testPageMetrics(); + void qtbug59443(); }; void tst_QPdfWriter::basics() @@ -245,6 +249,28 @@ void tst_QPdfWriter::testPageMetrics() QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf)); } +void tst_QPdfWriter::qtbug59443() +{ + // Do not crash or assert + QTemporaryFile file; + QVERIFY2(file.open(), qPrintable(file.errorString())); + QPdfWriter writer(file.fileName()); + writer.setPageSize(QPdfWriter::A4); + QTextDocument doc; + doc.documentLayout()->setPaintDevice(&writer); + + doc.setUndoRedoEnabled(false); + QTextCursor cursor(&doc); + QFont font = doc.defaultFont(); + font.setFamily("Calibri"); + font.setPointSize(8); + doc.setDefaultFont(font); + + cursor.insertText(QString::fromStdWString(L"기초하며, 베어링제조업체와 타\n")); + doc.print(&writer); + +} + QTEST_MAIN(tst_QPdfWriter) #include "tst_qpdfwriter.moc"